SaveTool: skip prereleases in update check.

This commit is contained in:
Guillaume Jacquemin 2021-12-02 20:37:47 +01:00
parent a05f3eeed0
commit 065e63f27c

View file

@ -402,22 +402,32 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
}; };
static const Version current_ver{SAVETOOL_VERSION}; static const Version current_ver{SAVETOOL_VERSION};
Version latest_ver{response[0]["tag_name"]};
if(latest_ver > current_ver || (latest_ver == current_ver && Utility::String::endsWith(SAVETOOL_VERSION, "-pre"))) { for(auto& release : response) {
_queue.addToast(Toast::Type::Warning, "Your version is out of date.\nCheck the settings for more information.", if(release["prerelease"] == true) {
std::chrono::milliseconds{5000}); continue;
_updateAvailable = true; }
_latestVersion = Utility::formatString("{}.{}.{}", latest_ver.major, latest_ver.minor, latest_ver.patch);
_releaseLink = response[0]["html_url"]; Version latest_ver{release["tag_name"]};
_downloadLink = response[0]["assets"][0]["browser_download_url"];
} if(latest_ver > current_ver || (latest_ver == current_ver && Utility::String::endsWith(SAVETOOL_VERSION, "-pre"))) {
else if(latest_ver == current_ver) { _queue.addToast(Toast::Type::Warning, "Your version is out of date.\nCheck the settings for more information.",
_queue.addToast(Toast::Type::Success, "The application is already up to date."); std::chrono::milliseconds{5000});
} _updateAvailable = true;
else if(current_ver > latest_ver) { _latestVersion = Utility::formatString("{}.{}.{}", latest_ver.major, latest_ver.minor, latest_ver.patch);
_queue.addToast(Toast::Type::Warning, "Your version is more recent than the latest one in the repo. How???"); _releaseLink = response[0]["html_url"];
_downloadLink = response[0]["assets"][0]["browser_download_url"];
}
else if(latest_ver == current_ver) {
_queue.addToast(Toast::Type::Success, "The application is already up to date.");
}
else if(current_ver > latest_ver) {
_queue.addToast(Toast::Type::Warning, "Your version is more recent than the latest one in the repo. How???");
}
break;
} }
} }
void SaveTool::initialiseConfiguration() { void SaveTool::initialiseConfiguration() {
@ -762,8 +772,7 @@ void SaveTool::checkGameState() {
} }
void SaveTool::checkForUpdates() { void SaveTool::checkForUpdates() {
cpr::Response r = cpr::Get(cpr::Url{"https://williamjcm.ovh/git/api/v1/repos/williamjcm/MassBuilderSaveTool/releases"}, cpr::Response r = cpr::Get(cpr::Url{"https://williamjcm.ovh/git/api/v1/repos/williamjcm/MassBuilderSaveTool/releases"}, cpr::Timeout{10000});
cpr::Parameters{{"limit", "1"}}, cpr::Timeout{10000});
SDL_Event event; SDL_Event event;
SDL_zero(event); SDL_zero(event);