Skip to content

Commit

Permalink
do not add files when watcher has been stopped
Browse files Browse the repository at this point in the history
  • Loading branch information
vdiez committed Aug 11, 2021
1 parent dd88b94 commit b1ed4a9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions watcher.js
Expand Up @@ -54,6 +54,7 @@ module.exports = class {
}

loop_watcher() {
if (!this.started) return;
if (this.connection.protocol === "fs") {
return fs.mkdirp(this.dirname, {mode: 0o2775})
.then(() => new Promise((resolve, reject) => {
Expand All @@ -76,6 +77,7 @@ module.exports = class {
bucket: this.bucket,
ignored: this.ignored,
on_file: (filename, stats) => {
if (!this.started) return;
if (!this.fileObjects[filename] || (this.fileObjects[filename] && stats.size !== this.fileObjects[filename].size)) {
this.logger.info(this.connection.protocol + " walk adding: ", filename);
this.on_file_added(filename, stats);
Expand Down Expand Up @@ -116,6 +118,8 @@ module.exports = class {
.then(() => {
this.started = false;
if (this.connection.protocol === "fs") return this.watcher?.close();
})
.then(() => {
clearTimeout(this.timeout);
this.polling = false;
this.fileObjects = {};
Expand Down

0 comments on commit b1ed4a9

Please sign in to comment.