SaveLib PR related fixes (#1011)

* Safety checks in all SFO readings

* SaveData: log backup error and continue & fix possible concurrent file editing

* SaveData: Fix issue with old firmwares
This commit is contained in:
Vinicius Rangel 2024-09-22 02:16:06 -03:00 committed by GitHub
parent edde0a3e7e
commit 581ddfec4d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 163 additions and 74 deletions

View file

@ -636,9 +636,19 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
QMessageBox msgBox;
msgBox.setWindowTitle(tr("PKG Extraction"));
psf.Open(pkg.sfo);
if (!psf.Open(pkg.sfo)) {
QMessageBox::critical(this, tr("PKG ERROR"),
"Could not read SFO. Check log for details");
return;
}
std::string content_id{*psf.GetString("CONTENT_ID")};
std::string content_id;
if (auto value = psf.GetString("CONTENT_ID"); value.has_value()) {
content_id = std::string{*value};
} else {
QMessageBox::critical(this, tr("PKG ERROR"), "PSF file there is no CONTENT_ID");
return;
}
std::string entitlement_label = Common::SplitString(content_id, '-')[2];
auto addon_extract_path = Common::FS::GetUserPath(Common::FS::PathType::AddonsDir) /
@ -647,11 +657,21 @@ void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int
auto category = psf.GetString("CATEGORY");
if (pkgType.contains("PATCH")) {
QString pkg_app_version =
QString::fromStdString(std::string{*psf.GetString("APP_VER")});
QString pkg_app_version;
if (auto app_ver = psf.GetString("APP_VER"); app_ver.has_value()) {
pkg_app_version = QString::fromStdString(std::string{*app_ver});
} else {
QMessageBox::critical(this, tr("PKG ERROR"), "PSF file there is no APP_VER");
return;
}
psf.Open(extract_path / "sce_sys" / "param.sfo");
QString game_app_version =
QString::fromStdString(std::string{*psf.GetString("APP_VER")});
QString game_app_version;
if (auto app_ver = psf.GetString("APP_VER"); app_ver.has_value()) {
game_app_version = QString::fromStdString(std::string{*app_ver});
} else {
QMessageBox::critical(this, tr("PKG ERROR"), "PSF file there is no APP_VER");
return;
}
double appD = game_app_version.toDouble();
double pkgD = pkg_app_version.toDouble();
if (pkgD == appD) {