This commit is contained in:
Benjamin Toby
2025-07-15 10:02:20 +01:00
parent 8865292893
commit a71614cb0f
18 changed files with 99 additions and 34 deletions
+9 -3
View File
@@ -79,13 +79,18 @@ function watchFolders(_a) {
sync({ dirPath, dirs, options });
yield (0, delay_1.default)();
fs_1.default.watch(dirPath, { recursive: true }, (evt, fileName) => {
if (global.SYNCING)
console.log("Folder Changed", evt, fileName);
if (fs_1.default.existsSync(global.SYNCING_FILE)) {
console.log("Existing Sync found. Returning ...");
return;
}
clearTimeout(timeout);
timeout = setTimeout(() => {
global.SYNCING = true;
console.log("Folder Syncing in progress ...");
console.log(`Writing Sync File =>${global.SYNCING_FILE}`);
fs_1.default.writeFileSync(global.SYNCING_FILE, `SYNCING Folder: evt:${evt} :: fileName:${fileName}`);
sync({ dirPath, dirs, options });
process.exit(1);
process.exit(global.SYNC_SUCCESS_EXIT_CODE);
}, INTERVAL);
});
}
@@ -159,4 +164,5 @@ function sync({ options, dirs, dirPath, init }) {
}
}
}
console.log("Folder Sync Complete. Exiting ...");
}