Only instantiate sparkle updater if autoupdating is available

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-02-23 15:03:51 +01:00 committed by Matthieu Gallien
parent 5f9837b2b2
commit c9275743d1
3 changed files with 11 additions and 4 deletions

View File

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

View 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];

View 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);