Skip to content

Commit 525d09d

Browse files
allow version info file without updateInfo
1 parent 9d2249a commit 525d09d

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/gui/gui.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ void PCSX::GUI::init(std::function<void()> applyArguments) {
598598
finishLoadSettings();
599599

600600
if (!g_system->getArgs().isUpdateDisabled() && emuSettings.get<PCSX::Emulator::SettingAutoUpdate>() &&
601-
!g_system->getVersion().failed()) {
601+
!g_system->getVersion().failed() && g_system->getVersion().hasUpdateInfo()) {
602602
m_update.downloadUpdateInfo(
603603
g_system->getVersion(),
604604
[this](bool success) {
@@ -1646,7 +1646,7 @@ their TV set to match the aspect ratio of the game.)"));
16461646
}
16471647

16481648
if (!g_system->getArgs().isUpdateDisabled() && !g_system->getVersion().failed() &&
1649-
!emuSettings.get<Emulator::SettingShownAutoUpdateConfig>().value) {
1649+
g_system->getVersion().hasUpdateInfo() && !emuSettings.get<Emulator::SettingShownAutoUpdateConfig>().value) {
16501650
if (ImGui::Begin(_("Update configuration"), nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
16511651
ImGui::TextUnformatted((_(R"(PCSX-Redux can automatically update itself.
16521652

src/support/version.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,22 @@ void PCSX::VersionInfo::loadFromFile(IO<File> file) {
4242
version = json["version"].template get<std::string>();
4343
changeset = json["changeset"].template get<std::string>();
4444
timestamp = json["timestamp"].template get<std::time_t>();
45+
} catch (...) {
46+
clear();
47+
return;
48+
}
49+
try {
4550
updateCatalog = json["updateInfo"][0]["updateCatalog"].template get<std::string>();
4651
updateInfoBase = json["updateInfo"][0]["updateInfoBase"].template get<std::string>();
4752
} catch (...) {
48-
clear();
53+
updateCatalog.clear();
54+
updateInfoBase.clear();
4955
}
5056
}
5157

5258
bool PCSX::Update::downloadUpdateInfo(const VersionInfo& versionInfo, std::function<void(bool)> callback,
5359
uv_loop_t* loop) {
54-
if (versionInfo.failed()) return false;
60+
if (versionInfo.failed() || !versionInfo.hasUpdateInfo()) return false;
5561
m_hasUpdate = false;
5662
m_download = new UvFile(
5763
versionInfo.updateCatalog,
@@ -89,7 +95,7 @@ bool PCSX::Update::downloadUpdateInfo(const VersionInfo& versionInfo, std::funct
8995

9096
bool PCSX::Update::downloadAndApplyUpdate(const VersionInfo& versionInfo, std::function<void(bool)> callback,
9197
uv_loop_t* loop) {
92-
if (versionInfo.failed()) return false;
98+
if (versionInfo.failed() || !versionInfo.hasUpdateInfo()) return false;
9399
m_hasUpdate = false;
94100
m_download = new UvFile(
95101
versionInfo.updateInfoBase + std::to_string(m_updateId),
@@ -124,7 +130,7 @@ bool PCSX::Update::downloadAndApplyUpdate(const VersionInfo& versionInfo, std::f
124130

125131
bool PCSX::Update::getDownloadUrl(const VersionInfo& versionInfo, std::function<void(std::string)> callback,
126132
uv_loop_t* loop) {
127-
if (versionInfo.failed()) return false;
133+
if (versionInfo.failed() || !versionInfo.hasUpdateInfo()) return false;
128134
m_hasUpdate = false;
129135
m_download = new UvFile(
130136
versionInfo.updateInfoBase + std::to_string(m_updateId),

src/support/version.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct VersionInfo {
4747
std::string updateInfoBase;
4848
void loadFromFile(IO<File> file);
4949
bool failed() const { return version.empty(); }
50+
bool hasUpdateInfo() const { return !updateInfoBase.empty(); }
5051
void clear() {
5152
version.clear();
5253
changeset.clear();

0 commit comments

Comments
 (0)