Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

fix(uninstall): let removal finish while Steam is open in another account

raymondchins3d831cb93367
diff --git a/app/Sources/BridgeplayApp/Model/SteamBundle.swift b/app/Sources/BridgeplayApp/Model/SteamBundle.swift
index 2cabf9b..75eb10f 100644
--- a/app/Sources/BridgeplayApp/Model/SteamBundle.swift
+++ b/app/Sources/BridgeplayApp/Model/SteamBundle.swift
@@ -107,9 +107,7 @@ enum SteamBundle {
onStopping: () -> Void = {}
) throws -> Bool {
guard client.runningAnywhere() else { return false }
- guard client.runningHere() else {
- throw StepFailure(step: step, detail: otherAccountRunning)
- }
+ guard client.runningHere() else { throw OpenInAnotherAccount(step: step) }
onStopping()
client.askToQuit()
@@ -123,9 +121,7 @@ enum SteamBundle {
detail: String(localized: "Steam did not quit. Quit Steam, then try again.")
)
}
- guard !client.runningAnywhere() else {
- throw StepFailure(step: step, detail: otherAccountRunning)
- }
+ guard !client.runningAnywhere() else { throw OpenInAnotherAccount(step: step) }
for pattern in sweepPatterns(app: app, helpers: helpers) {
client.sweep(pattern)
@@ -133,8 +129,16 @@ enum SteamBundle {
return true
}
- static let otherAccountRunning =
- String(localized: "Steam is open in another account on this Mac. Quit Steam in that account, then try again.")
+ // Its own type, so a caller that only touches this account's files can carry on.
+ struct OpenInAnotherAccount: LocalizedError {
+ let step: String
+ var errorDescription: String? {
+ StepFailure(
+ step: step,
+ detail: String(localized: "Steam is open in another account on this Mac. Quit Steam in that account, then try again.")
+ ).errorDescription
+ }
+ }
static func sweepPatterns(app: URL, helpers: [URL]) -> [String] {
([app] + helpers).map { url in
diff --git a/app/Sources/BridgeplayApp/Model/Uninstall.swift b/app/Sources/BridgeplayApp/Model/Uninstall.swift
index 889dcfc..3a5cd6f 100644
--- a/app/Sources/BridgeplayApp/Model/Uninstall.swift
+++ b/app/Sources/BridgeplayApp/Model/Uninstall.swift
@@ -166,7 +166,12 @@ enum Uninstall {
if !checkedClient {
let bundleLock = try DeploymentContent.acquireSteamLock(for: app, holding: lock)
defer { bundleLock.release() }
- stopped = try stop(app) { report(.stoppingClient) }
+ do {
+ stopped = try stop(app) { report(.stoppingClient) }
+ } catch is SteamBundle.OpenInAnotherAccount {
+ // Steam.app is left as it is from here on, and another account's Steam does
+ // not use this account's files.
+ }
}
_ = try SteamRepair.clearInsert(at: innerPlist)
_ = try UpdateBlock.remove(from: updateBlocks)
diff --git a/app/Tests/BridgeplayAppTests/SteamBundleTests.swift b/app/Tests/BridgeplayAppTests/SteamBundleTests.swift
index e50c2fe..059fb61 100644
--- a/app/Tests/BridgeplayAppTests/SteamBundleTests.swift
+++ b/app/Tests/BridgeplayAppTests/SteamBundleTests.swift
@@ -109,16 +109,15 @@ struct SteamBundleTests {
@Test("Steam open in another account stops the change without asking this one")
func otherAccountsSteamIsReported() {
let steam = FakeSteam(here: false, elsewhere: true)
- let failure = #expect(throws: StepFailure.self) { try stop(steam) }
- #expect(failure?.detail == SteamBundle.otherAccountRunning)
+ let failure = #expect(throws: SteamBundle.OpenInAnotherAccount.self) { try stop(steam) }
+ #expect(failure?.localizedDescription.contains("another account") == true)
#expect(steam.asked == 0)
}
@Test("Steam open in two accounts is reported once this one has quit")
func bothAccountsSteamIsReported() {
let steam = FakeSteam(here: true, elsewhere: true)
- let failure = #expect(throws: StepFailure.self) { try stop(steam) }
- #expect(failure?.detail == SteamBundle.otherAccountRunning)
+ #expect(throws: SteamBundle.OpenInAnotherAccount.self) { try stop(steam) }
#expect(steam.asked == 1)
#expect(steam.swept.isEmpty)
}