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
Improve text
NotProtonNot309d19892bba
diff --git a/app/Sources/NotProtonApp/Model/Uninstall.swift b/app/Sources/NotProtonApp/Model/Uninstall.swiftindex 8dcb2bd..729945e 100644--- a/app/Sources/NotProtonApp/Model/Uninstall.swift+++ b/app/Sources/NotProtonApp/Model/Uninstall.swift@@ -23,8 +23,11 @@ enum UninstallPhase: Sendable {struct UninstallOutcome: Sendable {let stoppedClient: Boollet detached: Bool+ let steamInstalled: Boollet restoredValveSignature: Boollet removed: [String]++ var steamNeedsRedownload: Bool { steamInstalled && !restoredValveSignature }}enum Uninstall {@@ -54,12 +57,14 @@ enum Uninstall {report(.detaching)let detached = try detach(from: app, innerPlist: innerPlist, updateBlocks: updateBlocks)- let restored: Bool- do {- try await repair { report(.restoring($0)) }- restored = true- } catch {- restored = false+ // Validate if Steam is present before restoring+ let steamInstalled = FileManager.default.fileExists(atPath: app.path(percentEncoded: false))+ var restored = false+ if steamInstalled {+ do {+ try await repair { report(.restoring($0)) }+ restored = true+ } catch {}}report(.removing)@@ -76,6 +81,7 @@ enum Uninstall {return UninstallOutcome(stoppedClient: stopped,detached: detached,+ steamInstalled: steamInstalled,restoredValveSignature: restored,removed: removed)diff --git a/app/Sources/NotProtonApp/Support/RemoveEverythingCommand.swift b/app/Sources/NotProtonApp/Support/RemoveEverythingCommand.swiftindex 3dfad3d..cde9e16 100644--- a/app/Sources/NotProtonApp/Support/RemoveEverythingCommand.swift+++ b/app/Sources/NotProtonApp/Support/RemoveEverythingCommand.swift@@ -18,18 +18,31 @@ enum RemoveEverythingCommand {output.say(phase.label)}output.say(- result.restoredValveSignature- ? "NotProton has been removed."- : "NotProton has been removed. Steam needs to be redownloaded. "- + "Please run Repair Steam again once you are online."+ result.steamNeedsRedownload+ ? "NotProton has been removed. Steam could not be restored. "+ + "Reinstall Steam from steampowered.com before using it again."+ : "NotProton has been removed.")return 0} catch {- FileHandle.standardError.write(Data("\(error.localizedDescription)\n".utf8))+ FileHandle.standardError.write(Data("\(failureMessage(error))\n".utf8))return 1}}+ static func failureMessage(_ error: Error) -> String {+ guard let refused = error as? WriteRefused else { return error.localizedDescription }+ let advice = switch refused.remedy {+ case .appManagement:+ "Allow your terminal app in System Settings > Privacy & Security > App Management, then run it again."+ case .otherAccount:+ "Steam was installed by another account on this Mac. Run this again while logged in to that account."+ case .ownership:+ "Check permissions, make sure your user owns the folder."+ }+ return "Could not write \(refused.path). \(advice)"+ }+private final class Output: @unchecked Sendable {private let lock = NSLock()private var last: String?diff --git a/app/Sources/NotProtonApp/SystemStatus.swift b/app/Sources/NotProtonApp/SystemStatus.swiftindex a047579..d08c436 100644--- a/app/Sources/NotProtonApp/SystemStatus.swift+++ b/app/Sources/NotProtonApp/SystemStatus.swift@@ -494,10 +494,10 @@ final class SystemStatus {defer { close(lock) }let result = try await Uninstall.run { progress($0.label) }- return result.restoredValveSignature- ? "NotProton has been removed."- : "NotProton has been removed. Steam needs to be redownloaded. "- + "Please run Repair Steam again once you are online."+ return result.steamNeedsRedownload+ ? "NotProton has been removed. Steam could not be restored. "+ + "Reinstall Steam from steampowered.com before using it again."+ : "NotProton has been removed."}}diff --git a/app/Tests/NotProtonAppTests/UninstallTests.swift b/app/Tests/NotProtonAppTests/UninstallTests.swiftindex a74a58e..4e7303c 100644--- a/app/Tests/NotProtonAppTests/UninstallTests.swift+++ b/app/Tests/NotProtonAppTests/UninstallTests.swift@@ -16,6 +16,13 @@ struct UninstallTests {var all: [UninstallPhase] { lock.lock(); defer { lock.unlock() }; return seen }}+ private final class Flag: @unchecked Sendable {+ private let lock = NSLock()+ private var raised = false+ func set() { lock.withLock { raised = true } }+ var value: Bool { lock.withLock { raised } }+ }+private struct Layout: Sendable {let root: URLlet app: URL@@ -228,6 +235,62 @@ struct UninstallTests {#expect(unpinnedWithoutLosingTheRest(layout.updateBlock))}+ @Test("A removal does not install Steam when there is none")+ func leavesAMissingSteamMissing() async throws {+ let layout = try layout()+ defer { try? FileManager.default.removeItem(at: layout.root) }+ try FileManager.default.removeItem(at: layout.app)+ let repaired = Flag()++ let outcome = try await Uninstall.run(+ app: layout.app,+ innerPlist: layout.innerPlist,+ updateBlocks: [layout.updateBlock],+ legacyCompat: layout.legacyCompat,+ compatTools: layout.compatTools,+ directories: [layout.support, layout.caches],+ libraries: [],+ repair: { _ in repaired.set() },+ stop: { _ in false }+ )++ #expect(!repaired.value)+ #expect(!outcome.steamInstalled)+ #expect(!outcome.steamNeedsRedownload)+ #expect(!FileManager.default.fileExists(atPath: layout.app.path(percentEncoded: false)))+ #expect(!FileManager.default.fileExists(atPath: layout.support.path(percentEncoded: false)))+ }++ @Test("A restore that fails asks for a redownload")+ func asksForARedownloadWhenTheRestoreFails() async throws {+ let layout = try layout()+ defer { try? FileManager.default.removeItem(at: layout.root) }+ struct Offline: Error {}++ let outcome = try await Uninstall.run(+ app: layout.app,+ innerPlist: layout.innerPlist,+ updateBlocks: [layout.updateBlock],+ legacyCompat: layout.legacyCompat,+ compatTools: layout.compatTools,+ directories: [layout.support, layout.caches],+ libraries: [],+ repair: { _ in throw Offline() },+ stop: { _ in false }+ )++ #expect(outcome.steamNeedsRedownload)+ }++ @Test("The command line names the path it could not write")+ func namesTheRefusedPath() {+ let path = "/nonexistent/Steam.app/Contents/Info.plist"+ let message = RemoveEverythingCommand.failureMessage(WriteRefused(path: path))+ #expect(message.hasPrefix("Could not write \(path). "))+ #expect(RemoveEverythingCommand.failureMessage(StepFailure(step: "x", detail: "Steam is running, please close Steam."))+ == StepFailure(step: "x", detail: "Steam is running, please close Steam.").localizedDescription)+ }+@Test("The copy the restore downloads is removed with everything else")func removesWhatTheRestoreLeavesBehind() async throws {let layout = try layout()