Procházet zdrojové kódy

Only instantiate sparkle updater if autoupdating is available

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
Claudio Cambra před 3 roky
rodič
revize
eb6118f35d

+ 2 - 0
src/gui/updater/sparkleupdater.h

@@ -36,6 +36,8 @@ public:
     SparkleUpdater(const QUrl &appCastUrl);
     ~SparkleUpdater();
 
+    static bool autoUpdaterAllowed();
+
     void setUpdateUrl(const QUrl &url);
 
     // unused in this updater

+ 1 - 2
src/gui/updater/sparkleupdater_mac.mm

@@ -260,8 +260,7 @@ void SparkleUpdater::setUpdateUrl(const QUrl &url)
     [_interface->updater setFeedURL: nsurl];
 }
 
-// FIXME: Should be changed to not instantiate the SparkleUpdater at all in this case
-bool autoUpdaterAllowed()
+bool SparkleUpdater::autoUpdaterAllowed()
 {
     // See https://github.com/owncloud/client/issues/2931
     NSString *bundlePath = [[NSBundle mainBundle] bundlePath];

+ 8 - 2
src/gui/updater/updater.cpp

@@ -57,7 +57,9 @@ QUrl Updater::updateUrl()
     auto urlQuery = getQueryParams();
 
 #if defined(Q_OS_MAC) && defined(HAVE_SPARKLE)
-    urlQuery.addQueryItem(QLatin1String("sparkle"), QLatin1String("true"));
+    if (SparkleUpdater::autoUpdaterAllowed()) {
+        urlQuery.addQueryItem(QLatin1String("sparkle"), QLatin1String("true"));
+    }
 #endif
 
 #if defined(Q_OS_WIN)
@@ -142,7 +144,11 @@ Updater *Updater::create()
     }
 
 #if defined(Q_OS_MACOS) && defined(HAVE_SPARKLE) && defined(BUILD_OWNCLOUD_OSX_BUNDLE)
-    return new SparkleUpdater(url);
+    if (SparkleUpdater::autoUpdaterAllowed()) {
+        return new SparkleUpdater(url);
+    }
+
+    return new PassiveUpdateNotifier(url);
 #elif defined(Q_OS_WIN32)
     // Also for MSI
     return new NSISUpdater(url);