mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 12:03:25 -08:00
Compare commits
3 commits
cc9cf9ba63
...
45662ac4e2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45662ac4e2 | ||
|
|
709d145422 | ||
|
|
fd8ed26555 |
1 changed files with 36 additions and 10 deletions
|
|
@ -27,6 +27,29 @@
|
||||||
|
|
||||||
#define GIT_SHORT_HASH_LEN 7
|
#define GIT_SHORT_HASH_LEN 7
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
|
||||||
|
// QSysInfo::productVersion() is not guaranteed to start with a number, e.g. it returns
|
||||||
|
// "Server 2022" on Windows Server. Use the first numeric token as the major host version.
|
||||||
|
std::optional<int> getProductVersionMajor()
|
||||||
|
{
|
||||||
|
const QString versionString = QSysInfo::productVersion();
|
||||||
|
bool ok = false;
|
||||||
|
static const QRegularExpression firstNumber(R"((\d+))");
|
||||||
|
const auto match = firstNumber.match(versionString);
|
||||||
|
const int version = match.hasMatch() ? match.captured(1).toInt(&ok) : 0;
|
||||||
|
if (!ok) {
|
||||||
|
qCWarning(ReleaseChannelLog) << "Unable to determine OS version from" << versionString;
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
ReleaseChannel::ReleaseChannel() : netMan(new QNetworkAccessManager(this)), response(nullptr), lastRelease(nullptr)
|
ReleaseChannel::ReleaseChannel() : netMan(new QNetworkAccessManager(this)), response(nullptr), lastRelease(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -47,18 +70,21 @@ void ReleaseChannel::checkForUpdates()
|
||||||
// Find assets compatible with host platform (Linux is not supported by in-client updater)
|
// Find assets compatible with host platform (Linux is not supported by in-client updater)
|
||||||
std::optional<int> ReleaseChannel::getTargetVersionForCurrentOS(const QString &fileName)
|
std::optional<int> ReleaseChannel::getTargetVersionForCurrentOS(const QString &fileName)
|
||||||
{
|
{
|
||||||
|
#if defined(Q_OS_WIN) && Q_PROCESSOR_WORDSIZE == 4
|
||||||
|
// The published Windows assets are 64-bit only
|
||||||
|
Q_UNUSED(fileName);
|
||||||
|
return std::nullopt;
|
||||||
|
#endif
|
||||||
|
|
||||||
const QRegularExpression *regex = nullptr;
|
const QRegularExpression *regex = nullptr;
|
||||||
|
|
||||||
static const std::optional<int> systemVersion = [] {
|
// Only platforms shipping updater assets (macOS, Windows) need the host version
|
||||||
bool ok = false;
|
static const std::optional<int> systemVersion =
|
||||||
const QString versionString = QSysInfo::productVersion();
|
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
|
||||||
const int version = versionString.split('.').first().toInt(&ok);
|
getProductVersionMajor();
|
||||||
if (!ok) {
|
#else
|
||||||
qCWarning(ReleaseChannelLog) << "Unable to determine OS version from" << versionString;
|
std::nullopt;
|
||||||
return std::optional<int>();
|
#endif
|
||||||
}
|
|
||||||
return std::optional<int>{version};
|
|
||||||
}();
|
|
||||||
|
|
||||||
if (!systemVersion) {
|
if (!systemVersion) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue