Updates
This commit is contained in:
Vendored
+7
-3
@@ -20,7 +20,8 @@ const delay_1 = __importDefault(require("../../utils/delay"));
|
||||
function watchFolders(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ folders, options, }) {
|
||||
let timeout;
|
||||
const UPDATE_TIMEOUT = 200;
|
||||
let isSyncing = false;
|
||||
const UPDATE_TIMEOUT = 500;
|
||||
try {
|
||||
const dirs = folders;
|
||||
console.log(`Now handling ${dirs.length} Directories`);
|
||||
@@ -80,7 +81,7 @@ function watchFolders(_a) {
|
||||
yield (0, delay_1.default)();
|
||||
fs_1.default.watch(dirPath, { recursive: true }, (evt, fileName) => {
|
||||
console.log("Folder Changed", evt, fileName);
|
||||
if (fs_1.default.existsSync(global.SYNCING_FILE)) {
|
||||
if (fs_1.default.existsSync(global.SYNCING_FILE) || isSyncing) {
|
||||
console.log("Existing Sync found. Returning ...");
|
||||
return;
|
||||
}
|
||||
@@ -89,8 +90,11 @@ function watchFolders(_a) {
|
||||
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}`);
|
||||
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