From 0bef268276a15fe8be12dfbdd577e5cd10bd1cb4 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Mon, 2 Oct 2017 21:28:32 -0600 Subject: [PATCH] Issue #122: If watch file exists at startup, kick off task/schedule --- core/event_scheduler.js | 7 +++++++ core/scanner_tossers/ftn_bso.js | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/core/event_scheduler.js b/core/event_scheduler.js index 27c68b37..8b3d3239 100644 --- a/core/event_scheduler.js +++ b/core/event_scheduler.js @@ -13,6 +13,7 @@ const pty = require('ptyw.js'); const sane = require('sane'); const moment = require('moment'); const paths = require('path'); +const fse = require('fs-extra'); exports.getModule = EventSchedulerModule; exports.EventSchedulerModule = EventSchedulerModule; // allow for loadAndStart @@ -245,6 +246,12 @@ EventSchedulerModule.prototype.startup = function(cb) { } }); }); + + fse.exists(schedEvent.schedule.watchFile, exists => { + if(exists) { + self.performAction(schedEvent, `Watch file: ${schedEvent.schedule.watchFile}`); + } + }); } }); } diff --git a/core/scanner_tossers/ftn_bso.js b/core/scanner_tossers/ftn_bso.js index 598667e8..57ff0525 100644 --- a/core/scanner_tossers/ftn_bso.js +++ b/core/scanner_tossers/ftn_bso.js @@ -1669,6 +1669,16 @@ FTNMessageScanTossModule.prototype.startup = function(cb) { } }); }); + + // + // If the watch file already exists, kick off now + // https://github.com/NuSkooler/enigma-bbs/issues/122 + // + fse.exists(importSchedule.watchFile, exists => { + if(exists) { + tryImportNow(`Performing import/toss due to @watch: ${importSchedule.watchFile} (initial exists)`); + } + }); } } }