From 26ce96297cd3ca014bc526cd4ef03c731ef7bbd9 Mon Sep 17 00:00:00 2001 From: crueter Date: Fri, 24 Apr 2026 18:40:49 +0200 Subject: [PATCH] [frontend] Change update checker to use new endpoints (#3879) Related: [RFC3870](https://git.eden-emu.dev/eden-emu/eden/issues/3870) Nightly and stable releases are now served through `nightly.eden-emu.dev` and `stable.eden-emu.dev`, respectively. These are stored using Backblaze, and served and cached through the Cloudflare CDN. Ideally this will reduce costs, though I'll have to wait for my first invoice to be certain. These will serve as the new download locations going forward. Since we have full control over this API, we can make any adjustments we want as needed. For now, all it does is provide `tag_name`, `name`, and `body`, the latter of which will be used for the upcoming updater PR. Signed-off-by: crueter Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3879 Reviewed-by: CamilleLaVey Reviewed-by: MaranBr --- CMakeModules/GenerateSCMRev.cmake | 10 ++--- src/android/app/src/main/jni/native.cpp | 14 +++---- src/frontend_common/update_checker.cpp | 53 +++++-------------------- src/frontend_common/update_checker.h | 2 +- 4 files changed, 21 insertions(+), 58 deletions(-) diff --git a/CMakeModules/GenerateSCMRev.cmake b/CMakeModules/GenerateSCMRev.cmake index 947a4963ee..2b028b4846 100644 --- a/CMakeModules/GenerateSCMRev.cmake +++ b/CMakeModules/GenerateSCMRev.cmake @@ -35,17 +35,17 @@ set(GIT_DESC ${BUILD_VERSION}) # Generate cpp with Git revision from template # Also if this is a CI build, add the build name (ie: Nightly, Canary) to the scm_rev file as well -# Auto-updater metadata! Must somewhat mirror GitHub API endpoint +# Auto-updater metadata! Must somewhat mirror GitHub/Forgejo API endpoint + +set(BUILD_AUTO_UPDATE_API_PATH "/latest/release.json") if (NIGHTLY_BUILD) set(BUILD_AUTO_UPDATE_WEBSITE "https://git.eden-emu.dev") - set(BUILD_AUTO_UPDATE_API "git.eden-emu.dev") - set(BUILD_AUTO_UPDATE_API_PATH "/api/v1/repos/") + set(BUILD_AUTO_UPDATE_API "nightly.eden-emu.dev") set(BUILD_AUTO_UPDATE_REPO "eden-ci/nightly") set(REPO_NAME "Eden Nightly") else() set(BUILD_AUTO_UPDATE_WEBSITE "https://git.eden-emu.dev") - set(BUILD_AUTO_UPDATE_API "git.eden-emu.dev") - set(BUILD_AUTO_UPDATE_API_PATH "/api/v1/repos/") + set(BUILD_AUTO_UPDATE_API "stable.eden-emu.dev") set(BUILD_AUTO_UPDATE_REPO "eden-emu/eden") set(REPO_NAME "Eden") endif() diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 210689ce55..93a1337d80 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -1726,9 +1726,8 @@ JNIEXPORT jstring JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_getUpdateUrl( jobject obj, jstring version) { const char* version_str = env->GetStringUTFChars(version, nullptr); - const std::string url = fmt::format("{}/{}/releases/tag/{}", - std::string{Common::g_build_auto_update_website}, - std::string{Common::g_build_auto_update_repo}, + const std::string url = fmt::format("{}/{}", + std::string{Common::g_build_auto_update_api}, version_str); env->ReleaseStringUTFChars(version, version_str); return env->NewStringUTF(url.c_str()); @@ -1760,11 +1759,10 @@ JNIEXPORT jstring JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_getUpdateApkUrl( } const std::string apk_filename = fmt::format("Eden-Android-{}-{}.apk", artifact_str, variant); - const std::string url = fmt::format("{}/{}/releases/download/{}/{}", - std::string{Common::g_build_auto_update_website}, - std::string{Common::g_build_auto_update_repo}, - version_str, - apk_filename); + + const std::string url = fmt::format("{}/{}/{}", + std::string{Common::g_build_auto_update_api}, + version_str, apk_filename); env->ReleaseStringUTFChars(tag, version_str); env->ReleaseStringUTFChars(artifact, artifact_str); diff --git a/src/frontend_common/update_checker.cpp b/src/frontend_common/update_checker.cpp index 1f01c25a26..71a94f38d4 100644 --- a/src/frontend_common/update_checker.cpp +++ b/src/frontend_common/update_checker.cpp @@ -80,55 +80,24 @@ std::optional UpdateChecker::GetResponse(std::string url, std::stri } } -std::optional UpdateChecker::GetLatestRelease(bool include_prereleases) { +std::optional UpdateChecker::GetLatestRelease() { #ifdef YUZU_BUNDLED_OPENSSL const auto update_check_url = fmt::format("https://{}", Common::g_build_auto_update_api); #else const auto update_check_url = std::string{Common::g_build_auto_update_api}; #endif - auto update_check_path = fmt::format("{}{}", std::string{Common::g_build_auto_update_api_path}, - std::string{Common::g_build_auto_update_repo}); + auto update_check_path = std::string{Common::g_build_auto_update_api_path}; try { - if (include_prereleases) { // This can return either a prerelease or a stable release, - // whichever is more recent. - const auto update_check_tags_path = update_check_path + "/tags"; - const auto update_check_releases_path = update_check_path + "/releases"; + const auto response = UpdateChecker::GetResponse(update_check_url, update_check_path); - const auto tags_response = UpdateChecker::GetResponse(update_check_url, update_check_tags_path); - const auto releases_response = UpdateChecker::GetResponse(update_check_url, update_check_releases_path); + if (!response) + return {}; - if (!tags_response || !releases_response) - return {}; - - const std::string latest_tag - = nlohmann::json::parse(tags_response.value()).at(0).at("name"); - const std::string latest_name = - nlohmann::json::parse(releases_response.value()).at(0).at("name"); - - const bool latest_tag_has_release = releases_response.value().find( - fmt::format("\"{}\"", latest_tag)) - != std::string::npos; - - // If there is a newer tag, but that tag has no associated release, don't prompt the - // user to update. - if (!latest_tag_has_release) - return {}; - - return Update{latest_tag, latest_name}; - } else { // This is a stable release, only check for other stable releases. - update_check_path += "/releases/latest"; - const auto response = UpdateChecker::GetResponse(update_check_url, update_check_path); - - if (!response) - return {}; - - const std::string latest_tag = nlohmann::json::parse(response.value()).at("tag_name"); - const std::string latest_name = nlohmann::json::parse(response.value()).at("name"); - - return Update{latest_tag, latest_name}; - } + const std::string latest_tag = nlohmann::json::parse(response.value()).at("tag_name"); + const std::string latest_name = nlohmann::json::parse(response.value()).at("name"); + return Update{latest_tag, latest_name}; } catch (nlohmann::detail::out_of_range&) { LOG_ERROR(Frontend, "Parsing JSON response from {}{} failed during update check: " @@ -147,12 +116,8 @@ std::optional UpdateChecker::GetLatestRelease(bool includ } std::optional UpdateChecker::GetUpdate() { - const bool is_prerelease = ((strstr(Common::g_build_version, "pre-alpha") != NULL) || - (strstr(Common::g_build_version, "alpha") != NULL) || - (strstr(Common::g_build_version, "beta") != NULL) || - (strstr(Common::g_build_version, "rc") != NULL)); const std::optional latest_release_tag = - UpdateChecker::GetLatestRelease(is_prerelease); + UpdateChecker::GetLatestRelease(); if (!latest_release_tag) goto empty; diff --git a/src/frontend_common/update_checker.h b/src/frontend_common/update_checker.h index fb6c25c3f3..307c38f202 100644 --- a/src/frontend_common/update_checker.h +++ b/src/frontend_common/update_checker.h @@ -18,6 +18,6 @@ typedef struct { } Update; std::optional GetResponse(std::string url, std::string path); -std::optional GetLatestRelease(bool include_prereleases); +std::optional GetLatestRelease(); std::optional GetUpdate(); } // namespace UpdateChecker