mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-23 16:07:52 -05:00
download latest loader resource if folder doesnt exist and the version doesnt exist
This commit is contained in:
parent
4b9b72f541
commit
28480a6dc4
1 changed files with 59 additions and 60 deletions
|
@ -740,14 +740,12 @@ void Loader::Impl::tryDownloadLoaderResources(
|
||||||
.expect([this, tryLatestOnError](std::string const& info, int code) {
|
.expect([this, tryLatestOnError](std::string const& info, int code) {
|
||||||
// if the url was not found, try downloading latest release instead
|
// if the url was not found, try downloading latest release instead
|
||||||
// (for development versions)
|
// (for development versions)
|
||||||
if (code == 404 && tryLatestOnError) {
|
if (code == 404) {
|
||||||
this->downloadLoaderResources(true);
|
log::warn("Unable to download resources: {}", info);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
ResourceDownloadEvent(
|
ResourceDownloadEvent(
|
||||||
UpdateFailed("Unable to download resources: " + info)
|
UpdateFailed("Unable to download resources: " + info)
|
||||||
).post();
|
).post();
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.progress([](auto&, double now, double total) {
|
.progress([](auto&, double now, double total) {
|
||||||
ResourceDownloadEvent(
|
ResourceDownloadEvent(
|
||||||
|
@ -768,7 +766,6 @@ void Loader::Impl::updateSpecialFiles() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Loader::Impl::downloadLoaderResources(bool useLatestRelease) {
|
void Loader::Impl::downloadLoaderResources(bool useLatestRelease) {
|
||||||
if (!useLatestRelease) {
|
|
||||||
web::AsyncWebRequest()
|
web::AsyncWebRequest()
|
||||||
.join("loader-tag-exists-check")
|
.join("loader-tag-exists-check")
|
||||||
.userAgent("github_api/1.0")
|
.userAgent("github_api/1.0")
|
||||||
|
@ -783,21 +780,10 @@ void Loader::Impl::downloadLoaderResources(bool useLatestRelease) {
|
||||||
this->getVersion().toString()
|
this->getVersion().toString()
|
||||||
), true);
|
), true);
|
||||||
})
|
})
|
||||||
.expect([this](std::string const& info, int code) {
|
.expect([=](std::string const& info, int code) {
|
||||||
if (code == 404) {
|
if (code == 404) {
|
||||||
log::debug("Loader version {} does not exist on Github, not downloading the resources", this->getVersion().toString());
|
if (useLatestRelease) {
|
||||||
ResourceDownloadEvent(
|
log::debug("Loader version {} does not exist on Github, downloading latest resources", this->getVersion().toString());
|
||||||
UpdateFinished()
|
|
||||||
).post();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ResourceDownloadEvent(
|
|
||||||
UpdateFailed("Unable to check if tag exists: " + info)
|
|
||||||
).post();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fetchLatestGithubRelease(
|
fetchLatestGithubRelease(
|
||||||
[this](json::Value const& raw) {
|
[this](json::Value const& raw) {
|
||||||
auto json = raw;
|
auto json = raw;
|
||||||
|
@ -827,6 +813,19 @@ void Loader::Impl::downloadLoaderResources(bool useLatestRelease) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
log::debug("Loader version {} does not exist on Github, not downloading the resources", this->getVersion().toString());
|
||||||
|
}
|
||||||
|
ResourceDownloadEvent(
|
||||||
|
UpdateFinished()
|
||||||
|
).post();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ResourceDownloadEvent(
|
||||||
|
UpdateFailed("Unable to check if tag exists: " + info)
|
||||||
|
).post();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Loader::Impl::verifyLoaderResources() {
|
bool Loader::Impl::verifyLoaderResources() {
|
||||||
|
@ -844,7 +843,7 @@ bool Loader::Impl::verifyLoaderResources() {
|
||||||
ghc::filesystem::is_directory(resourcesDir)
|
ghc::filesystem::is_directory(resourcesDir)
|
||||||
)) {
|
)) {
|
||||||
log::debug("Resources directory does not exist");
|
log::debug("Resources directory does not exist");
|
||||||
this->downloadLoaderResources();
|
this->downloadLoaderResources(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue