🔧 Chokidar tweaks
This commit is contained in:
@@ -177,77 +177,64 @@ export default class ApiService extends Service {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
fileWatcher
|
fileWatcher
|
||||||
.once(
|
.once("add", (path, stats) => {
|
||||||
"add",
|
console.log("Watcher detected new files.");
|
||||||
debounce((path, stats) => {
|
console.log(
|
||||||
console.log("Watcher detected new files.");
|
`File ${path} has been added with stats: ${JSON.stringify(
|
||||||
console.log(
|
stats,
|
||||||
`File ${path} has been added with stats: ${JSON.stringify(
|
null,
|
||||||
stats,
|
2
|
||||||
null,
|
)}`
|
||||||
2
|
);
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log("File copy started...");
|
console.log("File copy started...");
|
||||||
fs.stat(path, (err, stat) => {
|
fs.stat(path, (err, stat) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(
|
|
||||||
"Error watching file for copy completion. ERR: " +
|
|
||||||
err.message
|
|
||||||
);
|
|
||||||
console.log(
|
|
||||||
"Error file not processed. PATH: " +
|
|
||||||
path
|
|
||||||
);
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
setTimeout(
|
|
||||||
checkFileCopyComplete,
|
|
||||||
fileCopyDelaySeconds * 1000,
|
|
||||||
path,
|
|
||||||
stat
|
|
||||||
);
|
|
||||||
client.emit("action", {
|
|
||||||
type: "LS_COMIC_ADDED",
|
|
||||||
result: path,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}, 500)
|
|
||||||
)
|
|
||||||
.once(
|
|
||||||
"change",
|
|
||||||
debounce(
|
|
||||||
(path, stats) =>
|
|
||||||
console.log(
|
console.log(
|
||||||
`File ${path} has been changed. Stats: ${JSON.stringify(
|
"Error watching file for copy completion. ERR: " +
|
||||||
stats,
|
err.message
|
||||||
null,
|
);
|
||||||
2
|
console.log(
|
||||||
)}`
|
"Error file not processed. PATH: " +
|
||||||
),
|
path
|
||||||
500
|
);
|
||||||
)
|
throw err;
|
||||||
)
|
}
|
||||||
|
setTimeout(
|
||||||
|
checkFileCopyComplete,
|
||||||
|
fileCopyDelaySeconds * 1000,
|
||||||
|
path,
|
||||||
|
stat
|
||||||
|
);
|
||||||
|
client.emit("action", {
|
||||||
|
type: "LS_COMIC_ADDED",
|
||||||
|
result: path,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
// .once(
|
||||||
|
// "change",
|
||||||
|
|
||||||
|
// (path, stats) =>
|
||||||
|
// console.log(
|
||||||
|
// `File ${path} has been changed. Stats: ${JSON.stringify(
|
||||||
|
// stats,
|
||||||
|
// null,
|
||||||
|
// 2
|
||||||
|
// )}`
|
||||||
|
// )
|
||||||
|
// )
|
||||||
.once(
|
.once(
|
||||||
"unlink",
|
"unlink",
|
||||||
debounce(
|
|
||||||
(path) =>
|
(path) =>
|
||||||
console.log(
|
console.log(`File ${path} has been removed`)
|
||||||
`File ${path} has been removed`
|
|
||||||
),
|
|
||||||
500
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.once(
|
.once(
|
||||||
"addDir",
|
"addDir",
|
||||||
debounce(
|
|
||||||
(path) =>
|
(path) =>
|
||||||
console.log(
|
console.log(`Directory ${path} has been added`)
|
||||||
`Directory ${path} has been added`
|
|
||||||
),
|
|
||||||
500
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user