* Switch to sane over gaze for file watching: Gaze was not triggering on file additions

* Remove watching of config files for now -- doesn't work anyway. Will revisit later.
This commit is contained in:
Bryan Ashby 2017-10-02 21:06:53 -06:00
parent d5334270c4
commit 067bb9e884
4 changed files with 43 additions and 24 deletions

View file

@ -30,7 +30,7 @@ const fs = require('graceful-fs');
const later = require('later');
const temptmp = require('temptmp').createTrackedSession('ftn_bso');
const assert = require('assert');
const gaze = require('gaze');
const sane = require('sane');
const fse = require('fs-extra');
const iconv = require('iconv-lite');
const uuidV4 = require('uuid/v4');
@ -1654,10 +1654,18 @@ FTNMessageScanTossModule.prototype.startup = function(cb) {
}
if(_.isString(importSchedule.watchFile)) {
gaze(importSchedule.watchFile, (err, watcher) => {
watcher.on('all', (event, watchedPath) => {
if(importSchedule.watchFile === watchedPath) {
tryImportNow(`Performing import/toss due to @watch: ${watchedPath} (${event})`);
const watcher = sane(
paths.dirname(importSchedule.watchFile),
{
glob : `**/${paths.basename(importSchedule.watchFile)}`
}
);
[ 'change', 'add', 'delete' ].forEach(event => {
watcher.on(event, (fileName, fileRoot) => {
const eventPath = paths.join(fileRoot, fileName);
if(paths.join(fileRoot, fileName) === importSchedule.watchFile) {
tryImportNow(`Performing import/toss due to @watch: ${eventPath} (${event})`);
}
});
});