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
Only keep finished copies of CrossOver's original files
NotProtonNot431fe833c6ef
diff --git a/app/Sources/NotProtonApp/Model/RunnerPatcher.swift b/app/Sources/NotProtonApp/Model/RunnerPatcher.swiftindex 9d91add..ebfba03 100644--- a/app/Sources/NotProtonApp/Model/RunnerPatcher.swift+++ b/app/Sources/NotProtonApp/Model/RunnerPatcher.swift@@ -250,15 +250,21 @@ enum RunnerPatcher {return result.status == 0}- private static func keepClean(_ file: URL) throws {+ static func keepClean(_ file: URL, cp: String = "/bin/cp") throws {let backup = Clean.copy(of: file)guard backup == file else { return }let destination = file.appendingPathExtension(Clean.backupSuffix)- let result = try Shell.run("/bin/cp", [- "-p", file.path(percentEncoded: false), destination.path(percentEncoded: false),+ let staging = file.deletingLastPathComponent()+ .appending(path: ".\(destination.lastPathComponent).new")+ try? FileManager.default.removeItem(at: staging)+ defer { try? FileManager.default.removeItem(at: staging) }+ let result = try Shell.run(cp, [+ "-p", file.path(percentEncoded: false), staging.path(percentEncoded: false),])- guard result.status == 0 else {+ guard result.status == 0,+ rename(staging.path(percentEncoded: false), destination.path(percentEncoded: false)) == 0+ else {throw StepFailure(step: step,detail: String(localized: "Keeping the shipped \(file.lastPathComponent) failed. ")diff --git a/app/Tests/NotProtonAppTests/RunnerPatcherTests.swift b/app/Tests/NotProtonAppTests/RunnerPatcherTests.swiftindex 55036b8..72d6712 100644--- a/app/Tests/NotProtonAppTests/RunnerPatcherTests.swift+++ b/app/Tests/NotProtonAppTests/RunnerPatcherTests.swift@@ -120,6 +120,28 @@ struct RunnerPatcherTests {// The FEX flavor has only a wine.app in its arm64 directory, and a loader that is not found// never gets the dyld entitlement. Silent at install, it shows up as a game with no dylib.+ @Test("A backup cut short is not left behind as the clean copy")+ func cutShortBackupIsNotKept() throws {+ let dir = try scratchDirectory("keep-clean")+ defer { try? FileManager.default.removeItem(at: dir) }+ let file = dir.appending(path: "ntdll.dll")+ try Data(repeating: 0x5a, count: 1 << 20).write(to: file)+ let cp = dir.appending(path: "cp")+ try Data("#!/bin/sh\nulimit -f 128\nexec /bin/cp \"$@\"\n".utf8).write(to: cp)+ try FileManager.default.setAttributes(+ [.posixPermissions: 0o755], ofItemAtPath: cp.path(percentEncoded: false))++ #expect(throws: StepFailure.self) {+ try RunnerPatcher.keepClean(file, cp: cp.path(percentEncoded: false))+ }+ #expect(Clean.copy(of: file) == file)+ #expect(try FileManager.default.contentsOfDirectory(atPath: dir.path(percentEncoded: false)).sorted()+ == ["cp", "ntdll.dll"])++ try RunnerPatcher.keepClean(file)+ #expect(try Data(contentsOf: Clean.copy(of: file)) == Data(contentsOf: file))+ }+@Test("Loader discovery finds both the bare and the bundled layout")func loaderDiscoveryCoversBothLayouts() throws {let fm = FileManager.default