From 7a3deb649f9a0ea8a619f2f810da739b8d626689 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Mon, 27 Jul 2026 11:27:52 +0200 Subject: [PATCH] Fix package install failure warning message --- rpcs3/Crypto/unpkg.cpp | 26 ++++++++++++++++++++++---- rpcs3/Crypto/unpkg.h | 5 +++-- rpcs3/rpcs3qt/main_window.cpp | 26 +++++++++++++++----------- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/rpcs3/Crypto/unpkg.cpp b/rpcs3/Crypto/unpkg.cpp index 66fd5da416..ec1bebfa9a 100644 --- a/rpcs3/Crypto/unpkg.cpp +++ b/rpcs3/Crypto/unpkg.cpp @@ -653,7 +653,6 @@ bool package_reader::read_param_sfo() return false; } -// TODO: maybe also check if VERSION matches package_install_result package_reader::check_target_app_version() const { if (!m_is_valid) @@ -698,7 +697,13 @@ package_install_result package_reader::check_target_app_version() const { // We are unable to compare anything with the target app version pkg_log.error("A target app version is required (%s), but no PARAM.SFO was found for %s. (path='%s', error=%s)", target_app_ver, title_id, sfo_path, fs::g_tls_error); - return {package_install_result::error_type::app_version, {std::string(target_app_ver)}}; + return { + .error = package_install_result::error_type::app_version, + .version = { + .app_ver = std::string(app_ver), + .expected = std::string(target_app_ver) + } + }; } // There is nothing we need to compare, so we may install the package @@ -744,7 +749,13 @@ package_install_result package_reader::check_target_app_version() const } pkg_log.error("The new app version (%s) is smaller than the installed app version (%s)", app_ver, installed_app_ver); - return {package_install_result::error_type::app_version, {std::string(app_ver), std::string(installed_app_ver)}}; + return { + .error = package_install_result::error_type::app_version, + .version = { + .app_ver = std::string(app_ver), + .installed = std::string(installed_app_ver) + } + }; } // Check if the installed app version matches the target app version @@ -764,7 +775,14 @@ package_install_result package_reader::check_target_app_version() const } pkg_log.error("The installed app version (%s) does not match the target app version (%s)", installed_app_ver, target_app_ver); - return {package_install_result::error_type::app_version, {std::string(target_app_ver), std::string(installed_app_ver)}}; + return { + .error = package_install_result::error_type::app_version, + .version = { + .app_ver = std::string(app_ver), + .expected = std::string(target_app_ver), + .installed = std::string(installed_app_ver) + } + }; } bool package_reader::set_install_path() diff --git a/rpcs3/Crypto/unpkg.h b/rpcs3/Crypto/unpkg.h index 621d811207..4f03cdec16 100644 --- a/rpcs3/Crypto/unpkg.h +++ b/rpcs3/Crypto/unpkg.h @@ -305,10 +305,11 @@ struct package_install_result app_version, other } error = error_type::no_error; - struct version + struct versions { + std::string app_ver; std::string expected; - std::string found; + std::string installed; } version; }; diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 979606f580..f95c3d160f 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -1247,13 +1247,13 @@ bool main_window::HandlePackageInstallation(main_window* mw, QStringList file_pa { std::string resolved_path = Emu.GetCallbacks().resolve_path(it->first); - if (resolved_path.empty() || claimed_paths.count(resolved_path)) + if (resolved_path.empty() || claimed_paths.contains(resolved_path)) { it = paths.erase(it); } else { - claimed_paths.emplace(std::move(resolved_path)); + claimed_paths.insert(std::move(resolved_path)); it++; } } @@ -1326,23 +1326,27 @@ bool main_window::HandlePackageInstallation(main_window* mw, QStringList file_pa } const bool has_expected = !result.version.expected.empty(); - const bool has_found = !result.version.found.empty(); - if (has_expected && has_found) + const bool has_installed = !result.version.installed.empty(); + + if (has_expected && has_installed) { - QMessageBox::warning(mw, tr("Warning!"), tr("Package cannot be installed on top of the current data.\nUpdate is for version %1, but you have version %2.\n\nTried to install: %3") - .arg(QString::fromStdString(result.version.expected)).arg(QString::fromStdString(result.version.found)).arg(package->path)); + QMessageBox::warning(mw, tr("Warning!"), tr("Package cannot be installed on top of the current data.\nUpdate with version %0 is for version %1, but you have version %2.\n\nTried to install: %3") + .arg(QString::fromStdString(result.version.app_ver)).arg(QString::fromStdString(result.version.expected)).arg(QString::fromStdString(result.version.installed)).arg(package->path)); } else if (has_expected) { - QMessageBox::warning(mw, tr("Warning!"), tr("Package cannot be installed on top of the current data.\nUpdate is for version %1, but you don't have any data installed.\n\nTried to install: %2") - .arg(QString::fromStdString(result.version.expected)).arg(package->path)); + QMessageBox::warning(mw, tr("Warning!"), tr("Package cannot be installed on top of the current data.\nUpdate with version %0 is for version %1, but you don't have any data installed.\n\nTried to install: %2") + .arg(QString::fromStdString(result.version.app_ver)).arg(QString::fromStdString(result.version.expected)).arg(package->path)); + } + else if (has_installed) + { + QMessageBox::warning(mw, tr("Warning!"), tr("Package cannot be installed on top of the current data.\nUpdate has version %0, but you already have version %1.\n\nTried to install: %2") + .arg(QString::fromStdString(result.version.app_ver)).arg(QString::fromStdString(result.version.installed)).arg(package->path)); } else { // probably unreachable - const QString found = has_found ? tr("version %1").arg(QString::fromStdString(result.version.found)) : tr("no data installed"); - QMessageBox::warning(mw, tr("Warning!"), tr("Package cannot be installed on top of the current data.\nUpdate is for unknown version, but you have version %1.\n\nTried to install: %2") - .arg(QString::fromStdString(result.version.expected)).arg(found).arg(package->path)); + QMessageBox::warning(mw, tr("Warning!"), tr("Package cannot be installed on top of the current data.\nAn unexpected error occured.\n\nTried to install: %0").arg(package->path)); } } else