mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-19 17:39:50 -04:00
try fix updater sometimes skipping releases
This commit is contained in:
parent
68ba891d1a
commit
18dd0b75cb
1 changed files with 22 additions and 2 deletions
|
@ -51,12 +51,17 @@ void updater::fetchLatestGithubRelease(
|
|||
return then(s_latestGithubRelease.value());
|
||||
}
|
||||
|
||||
auto version = VersionInfo::parse(
|
||||
Mod::get()->getSavedValue("latest-version-auto-update-check", std::string("0.0.0"))
|
||||
);
|
||||
|
||||
log::debug("Last update check result: {}", version.unwrap().toString());
|
||||
|
||||
std::string modifiedSince;
|
||||
if (!force) {
|
||||
if (!force && version && version.unwrap() <= Mod::get()->getVersion() && version.unwrap() != VersionInfo(0, 0, 0)) {
|
||||
modifiedSince = Mod::get()->getSavedValue("last-modified-auto-update-check", std::string());
|
||||
}
|
||||
|
||||
// TODO: add header to not get rate limited
|
||||
web::AsyncWebRequest()
|
||||
.join("loader-auto-update-check")
|
||||
.header("If-Modified-Since", modifiedSince)
|
||||
|
@ -280,6 +285,8 @@ void updater::downloadLoaderUpdate(std::string const& url) {
|
|||
LoaderUpdateEvent(
|
||||
UpdateFailed("Unable to unzip update: " + unzip.unwrapErr())
|
||||
).post();
|
||||
|
||||
Mod::get()->setSavedValue("last-modified-auto-update-check", std::string());
|
||||
return;
|
||||
}
|
||||
s_isNewUpdateDownloaded = true;
|
||||
|
@ -290,6 +297,8 @@ void updater::downloadLoaderUpdate(std::string const& url) {
|
|||
LoaderUpdateEvent(
|
||||
UpdateFailed("Unable to download update: " + info)
|
||||
).post();
|
||||
|
||||
Mod::get()->setSavedValue("last-modified-auto-update-check", std::string());
|
||||
})
|
||||
.progress([](auto&, double now, double total) {
|
||||
LoaderUpdateEvent(
|
||||
|
@ -312,8 +321,16 @@ void updater::checkForLoaderUpdates() {
|
|||
VersionInfo ver { 0, 0, 0 };
|
||||
root.needs("tag_name").into(ver);
|
||||
|
||||
log::info("Latest version is {}", ver.toString());
|
||||
Mod::get()->setSavedValue("latest-version-auto-update-check", ver.toString());
|
||||
|
||||
// make sure release is newer
|
||||
if (ver <= Loader::get()->getVersion()) {
|
||||
if(ver <= VersionInfo(2, 0, 0, VersionTag(VersionTag::Beta, 1))) {
|
||||
log::warn("Invalid loader version detected, resetting update check time");
|
||||
|
||||
Mod::get()->setSavedValue("last-modified-auto-update-check", std::string());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -336,9 +353,12 @@ void updater::checkForLoaderUpdates() {
|
|||
}
|
||||
}
|
||||
|
||||
log::error("Failed to find release asset for " GEODE_PLATFORM_NAME);
|
||||
LoaderUpdateEvent(
|
||||
UpdateFailed("Unable to find release asset for " GEODE_PLATFORM_NAME)
|
||||
).post();
|
||||
|
||||
Mod::get()->setSavedValue("last-modified-auto-update-check", std::string());
|
||||
},
|
||||
[](std::string const& info) {
|
||||
log::error("Failed to fetch updates {}", info);
|
||||
|
|
Loading…
Reference in a new issue