From ff78e84efd4fa7fd75067807bd9aa8eabf44eff5 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Mon, 7 Mar 2022 14:02:50 +1100 Subject: [PATCH] Extend GitHub version check (#1863) * Extend GitHub version check to be done once per day when running in --monitor * Change notification to also notify GUI if notifications are being utilized --- src/log.d | 2 +- src/main.d | 17 +++++++++++++++-- src/util.d | 6 +++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/log.d b/src/log.d index eb3b6a1e..b7aa0da6 100644 --- a/src/log.d +++ b/src/log.d @@ -36,7 +36,7 @@ void init(string logDir) // we got an error .. writeln("\nUnable to access ", logFilePath); writeln("Please manually create '",logFilePath, "' and set appropriate permissions to allow write access"); - writeln("The requested client activity log will instead be located in your users home directory\n"); + writeln("The requested client activity log will instead be located in your users home directory"); } } } diff --git a/src/main.d b/src/main.d index 48d6441e..236d9fdc 100644 --- a/src/main.d +++ b/src/main.d @@ -689,8 +689,10 @@ int main(string[] args) return EXIT_FAILURE; } } - } else { - // Check application version and Initialize OneDrive API, check for authorization + } + + // Check application version and Initialize OneDrive API, check for authorization + if (online) { // Check Application Version log.vlog("Checking Application Version ..."); checkApplicationVersion(); @@ -1142,9 +1144,12 @@ int main(string[] args) bool performMonitor = true; ulong monitorLoopFullCount = 0; immutable auto checkInterval = dur!"seconds"(cfg.getValueLong("monitor_interval")); + immutable auto githubCheckInterval = dur!"seconds"(86400); immutable long logInterval = cfg.getValueLong("monitor_log_frequency"); immutable long fullScanFrequency = cfg.getValueLong("monitor_fullscan_frequency"); MonoTime lastCheckTime = MonoTime.currTime(); + MonoTime lastGitHubCheckTime = MonoTime.currTime(); + long logMonitorCounter = 0; long fullScanCounter = 0; // set fullScanRequired to true so that at application startup we perform a full walk @@ -1205,6 +1210,14 @@ int main(string[] args) // Skipping uploading this new file as parent path is not in the database: target/2eVPInOMTFNXzRXeNMEoJch5OR9XpGby // 'target' should be in the DB, it should also exist online, but because of --resync, it does not exist in the database thus parent check fails if (notificationReceived || (currTime - lastCheckTime > checkInterval) || (monitorLoopFullCount == 0)) { + // Check Application Version against GitHub once per day + if (currTime - lastGitHubCheckTime > githubCheckInterval) { + // --monitor GitHub Application Version Check time expired + checkApplicationVersion(); + // update when we have performed this check + lastGitHubCheckTime = MonoTime.currTime(); + } + // monitor sync loop logOutputMessage = "################################################## NEW LOOP ##################################################"; if (displaySyncOptions) { diff --git a/src/util.d b/src/util.d index b2ae6b9d..f90d6a85 100644 --- a/src/util.d +++ b/src/util.d @@ -388,7 +388,11 @@ void checkApplicationVersion() { // application version is older than available on GitHub if (applicationVersion < latestVersion) { // application version is obsolete and unsupported - log.log("\nWARNING: Your onedrive client is obsolete and unsupported. Please upgrade your client version.\n"); + writeln(); + log.logAndNotify("WARNING: Your onedrive client version is obsolete and unsupported. Please upgrade your client version."); + log.vlog("Application version: ", applicationVersion); + log.vlog("Version available: ", latestVersion); + writeln(); } } }