Update monitor mode logic

* Update where lastCheckTime is set - after the sync, not before
* Add in log to advise what the monitor sync interval is set to
This commit is contained in:
abraunegg 2018-08-04 06:19:55 +10:00
parent f385a0e24a
commit 7a864a2b4c

View file

@ -261,6 +261,7 @@ int main(string[] args)
if (monitor) {
log.vlog("Initializing monitor ...");
log.vlog("OneDrive monitor interval (seconds): ", to!long(cfg.getValue("monitor_interval")));
Monitor m = new Monitor(selectiveSync);
m.onDirCreated = delegate(string path) {
log.vlog("[M] Directory created: ", path);
@ -302,7 +303,6 @@ int main(string[] args)
if (!downloadOnly) m.update(online);
auto currTime = MonoTime.currTime();
if (currTime - lastCheckTime > checkInterval) {
lastCheckTime = currTime;
online = testNetwork();
if (online) {
performSync(sync, singleDirectory, downloadOnly, localFirst, uploadOnly);
@ -311,19 +311,19 @@ int main(string[] args)
m.update(false);
}
}
// performSync complete, set lastCheckTime to current time
lastCheckTime = currTime;
GC.collect();
} else {
Thread.sleep(dur!"msecs"(100));
}
}
}
}
// workaround for segfault in std.net.curl.Curl.shutdown() on exit
onedrive.http.shutdown();
return EXIT_SUCCESS;
}
// try to synchronize the folder three times