Updates
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user