Skip to content

Commit

Permalink
Make Program Updater choose the same build for download
Browse files Browse the repository at this point in the history
We're probably stuck offering the duo of RC_1_2 and RC_2_0 for some
time in the future. So hardcode the choices and make the Program Updater
choose the variant the user currently uses.
  • Loading branch information
sledgehammer999 committed Sep 11, 2024
1 parent 9a9c375 commit 1cc4de2
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/gui/programupdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

#include "programupdater.h"

#include <libtorrent/version.hpp>

#include <QtCore/qconfig.h>
#include <QtSystemDetection>
#include <QDebug>
#include <QDesktopServices>
Expand Down Expand Up @@ -61,6 +64,22 @@ namespace
}
return (newVersion > currentVersion);
}

QString buildVariant()
{
#if defined(Q_OS_MACOS)
const auto BASE_OS = u"Mac OS X"_s;
#elif defined(Q_OS_WIN)
const auto BASE_OS = u"Windows x64"_s;
#endif

if constexpr ((QT_VERSION_MAJOR == 6) && (LIBTORRENT_VERSION_MAJOR == 1))
return BASE_OS;
else
return u"%1 (qt%2 lt%3%4)"_s.arg(BASE_OS, QString::number(QT_VERSION_MAJOR), QString::number(LIBTORRENT_VERSION_MAJOR), QString::number(LIBTORRENT_VERSION_MINOR));

return {};
}
}

void ProgramUpdater::checkForUpdates() const
Expand Down Expand Up @@ -97,12 +116,7 @@ void ProgramUpdater::rssDownloadFinished(const Net::DownloadResult &result)
: QString {};
};

#ifdef Q_OS_MACOS
const QString OS_TYPE = u"Mac OS X"_s;
#elif defined(Q_OS_WIN)
const QString OS_TYPE = u"Windows x64"_s;
#endif

const QString variant = buildVariant();
bool inItem = false;
QString version;
QString updateLink;
Expand All @@ -128,7 +142,7 @@ void ProgramUpdater::rssDownloadFinished(const Net::DownloadResult &result)
{
if (inItem && (xml.name() == u"item"))
{
if (type.compare(OS_TYPE, Qt::CaseInsensitive) == 0)
if (type.compare(variant, Qt::CaseInsensitive) == 0)
{
qDebug("The last update available is %s", qUtf8Printable(version));
if (!version.isEmpty())
Expand Down

0 comments on commit 1cc4de2

Please sign in to comment.