Updates
This commit is contained in:
@@ -4,6 +4,8 @@ import watchFolders from "./watch/folders";
|
||||
|
||||
const confFileProvidedJSON = process.argv[process.argv.length - 1];
|
||||
|
||||
global.SYNCING = false;
|
||||
|
||||
try {
|
||||
const configFileObject = JSON.parse(confFileProvidedJSON);
|
||||
|
||||
|
||||
+4
-1
@@ -69,9 +69,11 @@ export default async function watchFiles({
|
||||
fs.watchFile(
|
||||
filePath,
|
||||
{
|
||||
interval: interval || 500,
|
||||
interval: interval || 200,
|
||||
},
|
||||
(curr, prev) => {
|
||||
if (global.SYNCING) return;
|
||||
|
||||
const INTERVAL = options?.interval
|
||||
? options.interval
|
||||
: UPDATE_TIMEOUT;
|
||||
@@ -79,6 +81,7 @@ export default async function watchFiles({
|
||||
clearTimeout(timeout);
|
||||
|
||||
timeout = setTimeout(() => {
|
||||
global.SYNCING = true;
|
||||
sync({ options, filePath, files });
|
||||
process.exit(1);
|
||||
}, INTERVAL);
|
||||
|
||||
@@ -5,7 +5,7 @@ import delay from "../../utils/delay";
|
||||
import { SyncFoldersFnParams, SyncFoldersSyncFnParams } from "../../types";
|
||||
|
||||
let timeout: any;
|
||||
const UPDATE_TIMEOUT = 2000;
|
||||
const UPDATE_TIMEOUT = 200;
|
||||
|
||||
export default async function watchFolders({
|
||||
folders,
|
||||
@@ -85,9 +85,11 @@ export default async function watchFolders({
|
||||
await delay();
|
||||
|
||||
fs.watch(dirPath, { recursive: true }, (evt, fileName) => {
|
||||
if (global.SYNCING) return;
|
||||
clearTimeout(timeout);
|
||||
|
||||
timeout = setTimeout(() => {
|
||||
global.SYNCING = true;
|
||||
sync({ dirPath, dirs, options });
|
||||
process.exit(1);
|
||||
}, INTERVAL);
|
||||
|
||||
Reference in New Issue
Block a user