Fix package install failure warning message

This commit is contained in:
Megamouse committed 2026-07-27 13:33:27 +02:00
1 parent a1deb2921c
commit 7a3deb649f
3 files changed
+40 -17

No files matched your search

+22 -4
View File
@@ -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()
+3 -2
View File
@@ -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;
};
+15 -11
View File
@@ -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