Respect skipAutoUpdateCheck in nextcloud.cfg with Sparkle on macOS
authorClaudio Cambra <claudio.cambra@gmail.com>
Mon, 11 Jul 2022 10:09:12 +0000 (12:09 +0200)
committerClaudio Cambra <claudio.cambra@gmail.com>
Fri, 15 Jul 2022 13:49:13 +0000 (15:49 +0200)
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
src/gui/updater/sparkleupdater_mac.mm

index 718a1e5e9c3410a5f2ce7f89dd98a42ca72ca923..a4e71042478932b413716230b1083becf18a3539 100644 (file)
@@ -19,6 +19,7 @@
 #include <AppKit/NSApplication.h>
 
 #include "common/utility.h"
+#include "configfile.h"
 #include "updater/sparkleupdater.h"
 
 @interface DelegateObject : NSObject <SUUpdaterDelegate>
@@ -119,17 +120,23 @@ void SparkleUpdater::setUpdateUrl(const QUrl &url)
     [d->updater setFeedURL: nsurl];
 }
 
-// FIXME: Should be changed to not instanicate the SparkleUpdater at all in this case
+// FIXME: Should be changed to not instantiate the SparkleUpdater at all in this case
 bool autoUpdaterAllowed()
 {
     // See https://github.com/owncloud/client/issues/2931
     NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
     NSString *expectedPath = [NSString stringWithFormat:@"/Applications/%@", [bundlePath lastPathComponent]];
-    if ([expectedPath isEqualTo:bundlePath]) {
-        return true;
+    if (![expectedPath isEqualTo:bundlePath]) {
+        qCWarning(lcUpdater) << "We are not in /Applications, won't check for update!";
+        return false;
     }
-    qCWarning(lcUpdater) << "We are not in /Applications, won't check for update!";
-    return false;
+
+    if(ConfigFile().skipUpdateCheck()) {
+        qCWarning(lcUpdater) << "Auto-updating has been set to skip in nextcloud.cfg, won't check for update.";
+        return false;
+    }
+
+    return true;
 }