This commit is contained in:
Benjamin Toby
2025-07-15 19:49:01 +01:00
parent 8a7c4530da
commit 5de4d1dc73
3 changed files with 15 additions and 7 deletions
+7 -3
View File
@@ -9,7 +9,8 @@ export default async function watchFolders({
options,
}: SyncFoldersFnParams) {
let timeout: any;
const UPDATE_TIMEOUT = 200;
let isSyncing = false;
const UPDATE_TIMEOUT = 500;
try {
const dirs = folders;
@@ -87,7 +88,7 @@ export default async function watchFolders({
fs.watch(dirPath, { recursive: true }, (evt, fileName) => {
console.log("Folder Changed", evt, fileName);
if (fs.existsSync(global.SYNCING_FILE)) {
if (fs.existsSync(global.SYNCING_FILE) || isSyncing) {
console.log("Existing Sync found. Returning ...");
return;
}
@@ -103,8 +104,11 @@ export default async function watchFolders({
global.SYNCING_FILE,
`SYNCING Folder: evt:${evt} :: fileName:${fileName}`
);
isSyncing = true;
sync({ dirPath, dirs, options });
process.exit(global.SYNC_SUCCESS_EXIT_CODE);
setTimeout(() => {
process.exit(global.SYNC_SUCCESS_EXIT_CODE);
}, INTERVAL);
}, INTERVAL);
});
}