Divide autoupdate paths for OS versions.

This commit is contained in:
John Preston 2019-09-10 01:21:44 +03:00
parent f9d10094ac
commit f463d3ec6d
5 changed files with 54 additions and 18 deletions

View File

@ -499,21 +499,7 @@ bool ParseCommonMap(
return false;
}
const auto platforms = document.object();
const auto platform = [&] {
if (Platform::IsWindows()) {
return "win";
} else if (Platform::IsMacOldBuild()) {
return "mac32";
} else if (Platform::IsMac()) {
return "mac";
} else if (Platform::IsLinux32Bit()) {
return "linux32";
} else if (Platform::IsLinux64Bit()) {
return "linux";
} else {
Unexpected("Platform in ParseCommonMap.");
}
}();
const auto platform = Platform::AutoUpdateKey();
const auto it = platforms.constFind(platform);
if (it == platforms.constEnd()) {
LOG(("Update Error: MTP platform '%1' not found in response."
@ -621,7 +607,11 @@ HttpChecker::HttpChecker(bool testing) : Checker(testing) {
}
void HttpChecker::start() {
auto url = QUrl(Local::readAutoupdatePrefix() + qstr("/current"));
const auto updaterVersion = Platform::AutoUpdateVersion();
const auto path = Local::readAutoupdatePrefix()
+ qstr("/current")
+ (updaterVersion > 1 ? QString::number(updaterVersion) : QString());
auto url = QUrl(path);
DEBUG_LOG(("Update Info: requesting update state"));
const auto request = QNetworkRequest(url);
_manager = std::make_unique<QNetworkAccessManager>();
@ -896,8 +886,10 @@ void MtpChecker::start() {
crl::on_main(this, [=] { fail(); });
return;
}
constexpr auto kFeed = "tdhbcfeed";
MTP::ResolveChannel(&_mtp, kFeed, [=](const MTPInputChannel &channel) {
const auto updaterVersion = Platform::AutoUpdateVersion();
const auto feed = "tdhbcfeed"
+ (updaterVersion > 1 ? QString::number(updaterVersion) : QString());
MTP::ResolveChannel(&_mtp, feed, [=](const MTPInputChannel &channel) {
_mtp.send(
MTPmessages_GetHistory(
MTP_inputPeerChannel(

View File

@ -42,4 +42,18 @@ QDate WhenSystemBecomesOutdated() {
return QDate();
}
int AutoUpdateVersion() {
return 2;
}
QString AutoUpdateKey() {
if (IsLinux32Bit()) {
return "linux32";
} else if (IsLinux64Bit()) {
return "linux";
} else {
Unexpected("Platform in AutoUpdateKey.");
}
}
} // namespace Platform

View File

@ -122,6 +122,23 @@ QDate WhenSystemBecomesOutdated() {
return QDate();
}
int AutoUpdateVersion() {
if (!IsMac10_10OrGreater()) {
return 1;
}
return 2;
}
QString AutoUpdateKey() {
if (IsMacOldBuild()) {
return "mac32";
} else if (!IsMac10_12OrGreater()) {
return "osx";
} else {
return "mac";
}
}
bool IsMac10_6OrGreater() {
return IsMacThatOrGreater<6>();
}

View File

@ -14,6 +14,8 @@ namespace Platform {
[[nodiscard]] QString SystemCountry();
[[nodiscard]] QString SystemLanguage();
[[nodiscard]] QDate WhenSystemBecomesOutdated();
[[nodiscard]] int AutoUpdateVersion();
[[nodiscard]] QString AutoUpdateKey();
[[nodiscard]] constexpr bool IsWindows();
[[nodiscard]] constexpr bool IsWindowsStoreBuild();

View File

@ -218,6 +218,17 @@ QDate WhenSystemBecomesOutdated() {
return QDate();
}
int AutoUpdateVersion() {
if (!IsWindows7OrGreater()) {
return 1;
}
return 2;
}
QString AutoUpdateKey() {
return "win";
}
bool IsWindowsXPOrGreater() {
static const auto result = ::IsWindowsXPOrGreater();
return result;