Play your Steam library's Windows games on a jailbroken PS5.
C++
Never delete files for a game whose folder went missing
Leonardo Lobato4b1b7fcfa064
diff --git a/src/runtime/package_installer.cpp b/src/runtime/package_installer.cppindex e49b645..4ede095 100644--- a/src/runtime/package_installer.cpp+++ b/src/runtime/package_installer.cpp@@ -368,7 +368,15 @@ bool MarkerIdentifies(const fs::path& path, const RuntimeInstall& record, const// The folder is named after the install id; the title id, kit and recipe can change// between installs (a reinstall can get another title), so they are not compared.bool StageMarkerNamesInstall(const fs::path& path, const RuntimeInstall& record, const std::string& kind) {- return MarkerHasLines(path, {"schema=1", "kind=" + kind, "install_id=" + record.install_id});+ // Strict: a marker with a repeated or malformed line names no install.+ const auto bytes = ReadBounded(path, 4096);+ if (!bytes) return false;+ const auto values = ParseMarker(*bytes);+ const auto value = [&](const char* key) {+ const auto found = values.find(key);+ return found == values.end() ? std::string() : found->second;+ };+ return value("schema") == "1" && value("kind") == kind && value("install_id") == record.install_id;}const playden::steam::json::Value* Required(diff --git a/src/steam/install_service.cpp b/src/steam/install_service.cppindex 25967df..a606ef7 100644--- a/src/steam/install_service.cpp+++ b/src/steam/install_service.cpp@@ -464,9 +464,10 @@ void InstallService::Uninstall(GameId id) {const auto found = std::find_if(installed_.begin(), installed_.end(), [id](const InstalledGame& game) { return game.id == id; });if (found == installed_.end()) return;// Nothing can be deleted on an absent drive. A game whose folder is missing from a present- // drive is forgotten (its removal finds nothing to delete).- if (const auto* volume = FindVolume(found->volume_id); !found->available && (!volume || !volume->available)) return;- const auto root = RootOn(found->volume_id, id);+ // drive is only forgotten: whatever its path names now isn't this install, so nothing is removed.+ const auto* volume = FindVolume(found->volume_id);+ if (!found->available && (!volume || !volume->available)) return;+ const auto root = found->available ? RootOn(found->volume_id, id) : std::string();installed_.erase(found);if (!root.empty()) removals_.push_back(root);Publish();diff --git a/tests/install_service_test.cpp b/tests/install_service_test.cppindex 69383b1..afead9a 100644--- a/tests/install_service_test.cpp+++ b/tests/install_service_test.cpp@@ -647,6 +647,9 @@ int main() {InstallService forget(multi, sessions, volumes);forget.Uninstall(800);AwaitAt(__LINE__, forget, [](const InstallSnapshot& s) { return !Installed(s, 800); });+ // Its path names no install now, so nothing is removed.+ std::lock_guard<std::mutex> lock(multi.mutex);+ CHECK(multi.removed.empty());}{Runner multi;diff --git a/tests/runtime_package_installer_test.cpp b/tests/runtime_package_installer_test.cppindex ca86d10..5169689 100644--- a/tests/runtime_package_installer_test.cpp+++ b/tests/runtime_package_installer_test.cpp@@ -763,6 +763,16 @@ void EarlierInstallStagingIsReclaimed() {CHECK(refusing.StageTitle(Record()).code == "staging-collision");CHECK(Read(other_staging / "eboot.bin") == "keep");+ // A marker that names two installs (a repeated install_id line) names neither.+ Fixture twice;+ auto strict = twice.Installer();+ const auto twice_staging = twice.host_data / ("playden/staging/title-" + Record().install_id);+ Write(twice_staging / ".playden-stage-owner",+ "schema=1\nkind=title\ninstall_id=install-other\ninstall_id=" + Record().install_id + "\n", 0600);+ Write(twice_staging / "eboot.bin", "keep", 0600);+ CHECK(strict.StageTitle(Record()).code == "staging-collision");+ CHECK(Read(twice_staging / "eboot.bin") == "keep");+Fixture bottle;auto copier = bottle.Installer();const auto bottle_staging = bottle.host_data / ("playden/staging/bottle-" + Record().install_id);