Play your Steam library's Windows games on a jailbroken PS5.
C++
Write a game's Steam facts before its install record
Leonardo Lobatoa7ff9cb40091
diff --git a/src/steam/backend/depot_installer.cpp b/src/steam/backend/depot_installer.cppindex 661c9c7..f641fe3 100644--- a/src/steam/backend/depot_installer.cpp+++ b/src/steam/backend/depot_installer.cpp@@ -1787,8 +1787,10 @@ InstallOutcome DepotInstaller::Run(const StoredSession& session, const InstallTaoutcome.progress = progress;return outcome;}- // The merged tree, then the install record; then drop the journal: the record marks a complete,- // verified install.+ // What goes with the record, the merged tree, then the install record; then drop the journal: the record marks a+ // complete, verified install, so everything else must be there first.+ if (target.before_apply && !target.before_apply(target.install_root, outcome.skipped_depots))+ return fail(InstallError::kStorage, "cannot finish install");if (!WriteText(target.install_root + "/" + kFileTree, tree_text())) return fail(InstallError::kStorage, "cannot write file tree");if (!WriteText(target.install_root + "/" + kInstallRecord, record_text()))return fail(InstallError::kStorage, "cannot write install record");diff --git a/src/steam/backend/depot_installer.h b/src/steam/backend/depot_installer.hindex a95bb5d..da00095 100644--- a/src/steam/backend/depot_installer.h+++ b/src/steam/backend/depot_installer.h@@ -50,9 +50,10 @@ struct InstallTarget {// everything is there they replace the game's files, files the new version dropped are deleted, and// the file tree, file list and record are written for the new version (see FinishUpdate).bool update = false;- // Update only, optional: called once every changed file is downloaded, before any of the game's files- // change, with the folder whose files go in place with the record (a ".playden-steam" there replaces- // the game's) and the depots the account was refused. False fails the update.+ // Optional: called once every file is downloaded, with the folder whose files go in place with the record (a+ // ".playden-steam" there replaces the game's) and the depots the account was refused: an install's own folder, right+ // before its record marks it complete, or for an update its work folder, before any of the game's files change.+ // False fails the install or update.std::function<bool(const std::string& folder, const std::vector<std::uint32_t>& skipped)> before_apply;// Update only, optional: asked right before the game's files start to change (also before an update// that stopped while putting them in place carries on). False (the game runs): the update stops withdiff --git a/src/steam/backend/steam_install_runner.cpp b/src/steam/backend/steam_install_runner.cppindex 2bc95a2..8b5c60f 100644--- a/src/steam/backend/steam_install_runner.cpp+++ b/src/steam/backend/steam_install_runner.cpp@@ -527,9 +527,10 @@ InstallRunner::Result SteamInstallRunner::Run(const StoredSession& session, std:.c_str());return written;};- // An update's facts go in place with its record.+ // The facts go in place with the record: a game with a record has them.target.update = update;- if (update) target.before_apply = write_facts, target.may_apply = may_apply;+ target.before_apply = write_facts;+ if (update) target.may_apply = may_apply;if (step) step(InstallStep::kDownloading);InstallPhase phase = InstallPhase::kDownloading;const auto outcome = installer_.Run(session, target, cancel, [&](const InstallProgress& state) {@@ -549,7 +550,6 @@ InstallRunner::Result SteamInstallRunner::Run(const StoredSession& session, std:}log("install", InstallErrorName(outcome.error), outcome.detail.c_str());result.ok = outcome.error == InstallError::kNone;- if (result.ok && !update) write_facts(root, outcome.skipped_depots);result.canceled = outcome.error == InstallError::kCanceled;// A running game holds the update back: it waits, its downloads kept, and tries again.result.retry_later = outcome.error == InstallError::kNetwork || outcome.error == InstallError::kGameRunning;diff --git a/tests/depot_installer_test.cpp b/tests/depot_installer_test.cppindex 1e83986..ccad6b0 100644--- a/tests/depot_installer_test.cpp+++ b/tests/depot_installer_test.cpp@@ -1014,6 +1014,32 @@ void RunStats(const std::filesystem::path& base) {}}+// What goes with the record is there before the record says the install is complete; if it can't be, neither is.+void FactsGoInBeforeTheRecord(const std::filesystem::path& root) {+ auto world = MakeWorld();+ DepotInstaller installer(world.Hooks());+ installer.SetTuning({1, 256});+ std::atomic<bool> cancel{false};+ auto target = Target(root);+ int calls = 0;+ target.before_apply = [&](const std::string& folder, const std::vector<std::uint32_t>&) {+ ++calls;+ CHECK(folder == root.string());+ CHECK(!std::filesystem::exists(root / DepotInstaller::kInstallRecord));+ return false;+ };+ CHECK(installer.Run({}, target, cancel).error == InstallError::kStorage);+ CHECK(calls == 1 && !std::filesystem::exists(root / DepotInstaller::kInstallRecord));+ target.before_apply = [&](const std::string& folder, const std::vector<std::uint32_t>&) {+ ++calls;+ std::ofstream(std::filesystem::path(folder) / ".playden-steam") << "nodlc=900\n";+ return true;+ };+ CHECK(installer.Run({}, target, cancel).error == InstallError::kNone);+ CHECK(calls == 2 && std::filesystem::exists(root / DepotInstaller::kInstallRecord));+ CHECK(Read(root / ".playden-steam") == "nodlc=900\n");+}+void InstallsMergedDepotsAndWritesRecord(const std::filesystem::path& root) {auto world = MakeWorld();for (std::uint8_t index = 0; index < 20; ++index) world.manifests[441].files[0].sha_content[index] = static_cast<std::uint8_t>(index * 13);@@ -2738,6 +2764,7 @@ int main(int argc, char** argv) {StorageFailureEndsStats(base / "storage-stats");StatsAndRemovalLogs(base / "removal");RunStats(base / "stats");+ FactsGoInBeforeTheRecord(base / "facts-before-record");InstallsMergedDepotsAndWritesRecord(base / "install");MeasureMatchesTheMergedInstall(base / "measure");LocalRecordNamesItsGame(base / "install-local");