Browse Source

Properly handle skipping auto update checks in the sparkle updater

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
Claudio Cambra 3 years ago
parent
commit
e85df6a791
1 changed files with 19 additions and 4 deletions
  1. 19 4
      src/gui/updater/sparkleupdater_mac.mm

+ 19 - 4
src/gui/updater/sparkleupdater_mac.mm

@@ -73,11 +73,24 @@ private:
     return self;
 }
 
+- (BOOL)backgroundUpdateChecksAllowed
+{
+    BOOL allowUpdateCheck = OCC::ConfigFile().skipUpdateCheck() ? NO : YES;
+    qCDebug(OCC::lcUpdater) << "Updater may check for updates:" << (allowUpdateCheck ? "YES" : "NO");
+    return allowUpdateCheck;
+}
+
 - (BOOL)updaterMayCheckForUpdates:(SUUpdater *)bundle
 {
     Q_UNUSED(bundle)
-    qCDebug(OCC::lcUpdater) << "Updater may check for updates: YES";
-    return YES;
+    return [self backgroundUpdateChecksAllowed];
+}
+
+- (BOOL)updaterShouldShowUpdateAlertForScheduledUpdate:(SUUpdater *)updater forItem:(SUAppcastItem *)item
+{
+    Q_UNUSED(updater)
+    Q_UNUSED(item)
+    return [self backgroundUpdateChecksAllowed];
 }
 
 - (void)notifyStateChange:(const OCC::SparkleUpdater::State)state displayStatus:(const QString&)statusString
@@ -288,9 +301,11 @@ void SparkleUpdater::checkForUpdate()
 
 void SparkleUpdater::backgroundCheckForUpdate()
 {
-    qCDebug(OCC::lcUpdater) << "launching background check";
-    if (autoUpdaterAllowed()) {
+    if (autoUpdaterAllowed() && !ConfigFile().skipUpdateCheck()) {
+        qCDebug(OCC::lcUpdater) << "launching background check";
         [_interface->updater checkForUpdatesInBackground];
+    } else {
+        qCDebug(OCC::lcUpdater) << "not launching background check, auto updater not allowed or update check skipped in config";
     }
 }