2026-01-31 01:18:36 +01:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
2025-10-01 05:07:59 +02:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
2025-05-28 02:23:51 +00:00
|
|
|
// Copyright Citra Emulator Project / Azahar Emulator Project
|
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
2026-04-28 20:42:23 +02:00
|
|
|
#ifdef NIGHTLY_BUILD
|
2026-02-01 20:38:02 +01:00
|
|
|
#include <boost/algorithm/string/classification.hpp>
|
|
|
|
|
#include <boost/algorithm/string/split.hpp>
|
2026-04-28 20:42:23 +02:00
|
|
|
#endif
|
2026-02-01 20:38:02 +01:00
|
|
|
|
|
|
|
|
#include <fmt/format.h>
|
2026-04-28 20:42:23 +02:00
|
|
|
#include "common/net/net.h"
|
2025-10-21 20:43:42 +02:00
|
|
|
#include "common/scm_rev.h"
|
2026-02-01 20:38:02 +01:00
|
|
|
#include "update_checker.h"
|
2025-10-21 20:43:42 +02:00
|
|
|
|
2026-04-28 20:42:23 +02:00
|
|
|
#include "common/logging.h"
|
2025-10-21 20:43:42 +02:00
|
|
|
|
2026-04-28 20:42:23 +02:00
|
|
|
std::optional<Common::Net::Release> UpdateChecker::GetUpdate() {
|
|
|
|
|
const auto latest = Common::Net::GetLatestRelease();
|
|
|
|
|
if (!latest) return std::nullopt;
|
2025-05-28 02:23:51 +00:00
|
|
|
|
2026-04-28 20:42:23 +02:00
|
|
|
LOG_INFO(Frontend, "Received update {}", latest->title);
|
2025-05-28 02:23:51 +00:00
|
|
|
|
2026-04-28 20:42:23 +02:00
|
|
|
#ifdef NIGHTLY_BUILD
|
|
|
|
|
std::vector<std::string> result;
|
2025-05-28 02:23:51 +00:00
|
|
|
|
2026-04-28 20:42:23 +02:00
|
|
|
boost::split(result, latest->tag, boost::is_any_of("."));
|
|
|
|
|
if (result.size() != 2)
|
|
|
|
|
return std::nullopt;
|
2025-10-21 20:43:42 +02:00
|
|
|
|
2026-04-28 20:42:23 +02:00
|
|
|
const std::string tag = result[1];
|
2025-05-28 02:23:51 +00:00
|
|
|
|
2026-04-28 20:42:23 +02:00
|
|
|
boost::split(result, std::string{Common::g_build_version}, boost::is_any_of("-"));
|
|
|
|
|
if (result.empty())
|
2025-10-21 20:43:42 +02:00
|
|
|
return std::nullopt;
|
2025-05-28 02:23:51 +00:00
|
|
|
|
2026-04-28 20:42:23 +02:00
|
|
|
const std::string build = result[0];
|
2026-03-15 02:57:32 +01:00
|
|
|
#else
|
2026-04-28 20:42:23 +02:00
|
|
|
const std::string tag = latest->tag;
|
|
|
|
|
const std::string build = Common::g_build_version;
|
2026-03-15 02:57:32 +01:00
|
|
|
#endif
|
|
|
|
|
|
2026-04-28 20:42:23 +02:00
|
|
|
if (tag != build)
|
|
|
|
|
return latest;
|
2026-02-01 20:38:02 +01:00
|
|
|
|
2026-02-01 22:27:49 +01:00
|
|
|
return std::nullopt;
|
2026-02-01 20:38:02 +01:00
|
|
|
}
|