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
Remove Everything also removes empty prefix template
NotProtonNota3228a70c90b
diff --git a/app/Sources/NotProtonApp/Model/RunnerInstaller.swift b/app/Sources/NotProtonApp/Model/RunnerInstaller.swiftindex f4f24be..3646c2b 100644--- a/app/Sources/NotProtonApp/Model/RunnerInstaller.swift+++ b/app/Sources/NotProtonApp/Model/RunnerInstaller.swift@@ -107,10 +107,12 @@ enum RunnerInstaller {}static func removePrefixTemplates(- keeping builds: Set<String>, libraries: [SteamLibrary], reportBusy: Bool = true+ keeping builds: Set<String>, libraries: [SteamLibrary], reportBusy: Bool = true,+ removingFolder: Bool = false) -> [StepFailure] {var failures: [StepFailure] = []for library in libraries {+ let earlierFailures = failures.countlet kept = Set(builds.flatMap {SupportPaths.prefixTemplates(forBuild: $0, in: library).map(\.lastPathComponent)})@@ -160,6 +162,10 @@ enum RunnerInstaller {))}}+ if removingFolder, builds.isEmpty, failures.count == earlierFailures,+ unlinkat(parent, SupportPaths.prefixTemplateFolder, AT_REMOVEDIR) == 0 {+ unlinkat(parent, ".notproton-template.lock", 0)+ }} catch {failures.append(StepFailure(step: removeStep,diff --git a/app/Sources/NotProtonApp/Model/Uninstall.swift b/app/Sources/NotProtonApp/Model/Uninstall.swiftindex f0c5ae5..8dcb2bd 100644--- a/app/Sources/NotProtonApp/Model/Uninstall.swift+++ b/app/Sources/NotProtonApp/Model/Uninstall.swift@@ -66,7 +66,8 @@ enum Uninstall {let removed = try remove(legacyCompat: legacyCompat, compatTools: compatTools, directories: directories)- let templateFailures = RunnerInstaller.removePrefixTemplates(keeping: [], libraries: libraries)+ let templateFailures = RunnerInstaller.removePrefixTemplates(+ keeping: [], libraries: libraries, removingFolder: true)if !templateFailures.isEmpty {throw StepFailure(step: step, detail: templateFailures.map(\.detail).joined(separator: "\n"))}diff --git a/app/Tests/NotProtonAppTests/TemplateCleanupTests.swift b/app/Tests/NotProtonAppTests/TemplateCleanupTests.swiftindex 9ae2ea4..e8c158a 100644--- a/app/Tests/NotProtonAppTests/TemplateCleanupTests.swift+++ b/app/Tests/NotProtonAppTests/TemplateCleanupTests.swift@@ -82,6 +82,33 @@ struct TemplateCleanupTests {#expect(!FileManager.default.fileExists(atPath: layout.template.path))}+ @Test("Removing every build takes the empty template folder and its lock but no game prefix")+ func fullRemovalTakesFolderAndLock() throws {+ let layout = try Layout()+ defer { try? FileManager.default.removeItem(at: layout.root) }+ let save = layout.library.compatdata.appending(path: "700330/pfx/drive_c/save.dat")+ try FileManager.default.createDirectory(at: save.deletingLastPathComponent(), withIntermediateDirectories: true)+ try Data("save".utf8).write(to: save)++ #expect(RunnerInstaller.removePrefixTemplates(keeping: [], libraries: [layout.library], removingFolder: true).isEmpty)++ #expect(!FileManager.default.fileExists(atPath: layout.folder.path))+ #expect(!FileManager.default.fileExists(atPath: layout.lock.path))+ #expect(FileManager.default.fileExists(atPath: save.path))+ }++ @Test("A template folder with unknown files keeps the folder and its lock")+ func unknownFilesKeepFolderAndLock() throws {+ let layout = try Layout()+ defer { try? FileManager.default.removeItem(at: layout.root) }+ try Data("keep".utf8).write(to: layout.folder.appending(path: "notes"))++ #expect(RunnerInstaller.removePrefixTemplates(keeping: [], libraries: [layout.library], removingFolder: true).isEmpty)++ #expect(FileManager.default.fileExists(atPath: layout.folder.appending(path: "notes").path))+ #expect(FileManager.default.fileExists(atPath: layout.lock.path))+ }+@MainActor@Test("The bridge copies on every drive are counted once")func countsBridgeCopies() async throws {