Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
fix(install): report a failed revert of Steam's Info.plist
raymondchins70a9c1799ef2
diff --git a/app/Sources/BridgeplayApp/Model/SteamInstaller.swift b/app/Sources/BridgeplayApp/Model/SteamInstaller.swiftindex f5db99e..e2faa87 100644--- a/app/Sources/BridgeplayApp/Model/SteamInstaller.swift+++ b/app/Sources/BridgeplayApp/Model/SteamInstaller.swift@@ -191,7 +191,12 @@ enum SteamInstaller {try sign(app.appending(path: "Contents/MacOS/steam_osx"), identity: identity)try sign(app, identity: identity)} catch {- revertPlist(priorPlist, at: plist, app: app)+ do {+ try revertPlist(priorPlist, at: plist, app: app)+ } catch let revertFailure {+ AppLog.note("install: putting the plist back failed: \(revertFailure.localizedDescription)")+ throw StepFailure(step: step, detail: error.localizedDescription + " " + String(localized: "Putting Steam back as it was also failed, so Steam may not start: \(revertFailure.localizedDescription) Use Repair Steam to restore it."))+ }throw error}// macOS keys Steam's input access to the designated requirement. Ad hoc that is the@@ -367,10 +372,12 @@ enum SteamInstaller {return true}- static func revertPlist(_ bytes: Data?, at plist: URL, app: URL) {+ // Throws when either half fails: a plist that still declares the insert, or a bundle+ // whose seal no longer matches it, is a Steam that does not start.+ static func revertPlist(_ bytes: Data?, at plist: URL, app: URL) throws {guard let bytes else { return }- try? bytes.write(to: plist)- try? adHocSign(app)+ try WriteRefused.catching(plist) { try bytes.write(to: plist) }+ try adHocSign(app)}static func setInsert(at plist: URL, to dylib: URL) throws {diff --git a/app/Tests/BridgeplayAppTests/SteamInstallerTests.swift b/app/Tests/BridgeplayAppTests/SteamInstallerTests.swiftindex ad57647..b0718aa 100644--- a/app/Tests/BridgeplayAppTests/SteamInstallerTests.swift+++ b/app/Tests/BridgeplayAppTests/SteamInstallerTests.swift@@ -322,6 +322,21 @@ struct SteamInstallerTests {#expect(!FileManager.default.fileExists(atPath: fixture.deployedVersion.path))}+ // Both halves used to be try?, so a Steam left with the insert reported nothing.+ @Test("Putting the plist back reports a write it could not make")+ func revertReportsItsOwnFailure() throws {+ let work = try scratchDirectory("install")+ defer { try? FileManager.default.removeItem(at: work) }+ let missing = work.appending(path: "gone/Steam.app")++ #expect(throws: (any Error).self) {+ try SteamInstaller.revertPlist(Data("plist".utf8), at: missing.appending(path: "Contents/Info.plist"), app: missing)+ }+ #expect(throws: Never.self) {+ try SteamInstaller.revertPlist(nil, at: missing.appending(path: "Contents/Info.plist"), app: missing)+ }+ }+@Test("The plist backup records the state before the first install only")func backsUpOriginalPlistOnce() async throws {let work = try scratchDirectory("install")