Play your Steam library's Windows games on a jailbroken PS5.
C++
Keep games listed when their folder is missing
Leonardo Lobatoda142007025c
diff --git a/src/steam/install_service.cpp b/src/steam/install_service.cppindex ac84a9a..25967df 100644--- a/src/steam/install_service.cpp+++ b/src/steam/install_service.cpp@@ -237,6 +237,11 @@ void InstallService::Scan() {}job.view.volume_id = entry.volume_id;jobs_.push_back(job);+ } else if (entry.install_bytes > 0) {+ // The drive is there but the game's folder isn't (moved aside or renamed): keep the game+ // listed as unavailable, so it comes back with its folder instead of being forgotten at+ // the next save.+ installed_.push_back({entry.id, entry.install_bytes, root, entry.volume_id, false});}}std::sort(installed_.begin(), installed_.end(),@@ -457,7 +462,10 @@ void InstallService::Cancel(GameId id) {void InstallService::Uninstall(GameId id) {std::lock_guard<std::mutex> lock(mutex_);const auto found = std::find_if(installed_.begin(), installed_.end(), [id](const InstalledGame& game) { return game.id == id; });- if (found == installed_.end() || !found->available) return; // nothing can be deleted on an absent drive+ 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);installed_.erase(found);if (!root.empty()) removals_.push_back(root);diff --git a/src/steam/install_service.h b/src/steam/install_service.hindex c65c5d6..0c23058 100644--- a/src/steam/install_service.h+++ b/src/steam/install_service.h@@ -60,7 +60,7 @@ struct InstalledGame {std::uint64_t install_bytes = 0;std::string root;std::string volume_id;- bool available = true; // false while the game's volume is absent+ bool available = true; // false while the game's volume, or its folder on that volume, is missingstd::int64_t finished_at = 0; // Unix seconds the install finished (its record's time); 0 unknown};diff --git a/tests/install_service_test.cpp b/tests/install_service_test.cppindex a1b7dbf..69383b1 100644--- a/tests/install_service_test.cpp+++ b/tests/install_service_test.cpp@@ -616,6 +616,44 @@ int main() {if (game.id == 500) CHECK(game.volume_id == "usb0" && !game.available && game.install_bytes == 1234);}}+ {+ // A game whose folder is missing from a present drive stays listed, unavailable, and is+ // saved again; it is available once its folder is back, and Uninstall can forget it.+ std::filesystem::rename(second / "800", second / "800.aside");+ {+ Runner multi;+ InstallService missing(multi, sessions, volumes);+ bool listed = false;+ for (const auto& game : missing.Snapshot().installed)+ if (game.id == 800) listed = !game.available && game.volume_id == "m2" && game.install_bytes > 0;+ CHECK(listed);+ missing.SetDefaultVolume("internal"); // any save writes the registry again+ missing.SetDefaultVolume("m2");+ missing.Install(900);+ AwaitAt(__LINE__, missing, [](const InstallSnapshot& s) { return Installed(s, 900); });+ }+ std::filesystem::rename(second / "800.aside", second / "800");+ {+ Runner multi;+ InstallService back(multi, sessions, volumes);+ bool available = false;+ for (const auto& game : back.Snapshot().installed)+ if (game.id == 800) available = game.available;+ CHECK(available);+ }+ std::filesystem::rename(second / "800", second / "800.aside");+ {+ Runner multi;+ InstallService forget(multi, sessions, volumes);+ forget.Uninstall(800);+ AwaitAt(__LINE__, forget, [](const InstallSnapshot& s) { return !Installed(s, 800); });+ }+ {+ Runner multi;+ InstallService after(multi, sessions, volumes);+ CHECK(!Installed(after.Snapshot(), 800));+ }+ }{// A remembered default whose drive is now absent falls back to the primary volume.auto without_m2 = volumes;