]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Only instantiate sparkle updater if autoupdating is available
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Thu, 23 Feb 2023 14:03:51 +0000 (15:03 +0100)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Sat, 22 Jul 2023 09:16:39 +0000 (11:16 +0200)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/updater/sparkleupdater.h
src/gui/updater/sparkleupdater_mac.mm
src/gui/updater/updater.cpp

index fab3050baaaa2fdaefaa63cf9423e696a2c7f13d..c3ccc5f01689e03028ed209f3999d8eabcbc137d 100644 (file)
@@ -36,6 +36,8 @@ public:
     SparkleUpdater(const QUrl &appCastUrl);
     ~SparkleUpdater();
 
+    static bool autoUpdaterAllowed();
+
     void setUpdateUrl(const QUrl &url);
 
     // unused in this updater
index 71650454cff1744051199544d71c347bba00ee83..57dd04a1ca4956b207446cbd6842ccf708cb3fde 100644 (file)
@@ -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];
index cb3dd310738ca984931e5361a6c686d73883e15a..46393fcfb9cacaa36c2e5fd4596731b72a95460f 100644 (file)
@@ -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);