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 a template lock issue
NotProtonNot3c3a679100b8
diff --git a/app/Sources/NotProtonApp/Model/RunnerInstaller.swift b/app/Sources/NotProtonApp/Model/RunnerInstaller.swiftindex 3646c2b..1064350 100644--- a/app/Sources/NotProtonApp/Model/RunnerInstaller.swift+++ b/app/Sources/NotProtonApp/Model/RunnerInstaller.swift@@ -162,9 +162,8 @@ enum RunnerInstaller {))}}- if removingFolder, builds.isEmpty, failures.count == earlierFailures,- unlinkat(parent, SupportPaths.prefixTemplateFolder, AT_REMOVEDIR) == 0 {- unlinkat(parent, ".notproton-template.lock", 0)+ if removingFolder, builds.isEmpty, failures.count == earlierFailures {+ unlinkat(parent, SupportPaths.prefixTemplateFolder, AT_REMOVEDIR)}} catch {failures.append(StepFailure(diff --git a/app/Tests/NotProtonAppTests/TemplateCleanupTests.swift b/app/Tests/NotProtonAppTests/TemplateCleanupTests.swiftindex e8c158a..2fb9111 100644--- a/app/Tests/NotProtonAppTests/TemplateCleanupTests.swift+++ b/app/Tests/NotProtonAppTests/TemplateCleanupTests.swift@@ -82,19 +82,30 @@ 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 {+ @Test("Removing every build takes the empty template folder but keeps the lock and game prefixes")+ func fullRemovalKeepsLockAndPrefixes() 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)+ let opened = open(layout.lock.path, O_RDWR | O_CREAT, 0o600)+ #expect(opened >= 0)+ guard opened >= 0 else { return }+ defer { close(opened) }#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: layout.lock.path))#expect(FileManager.default.fileExists(atPath: save.path))+ #expect(flock(opened, LOCK_EX | LOCK_NB) == 0)+ let next = open(layout.lock.path, O_RDWR | O_CREAT, 0o600)+ #expect(next >= 0)+ guard next >= 0 else { return }+ defer { close(next) }+ #expect(flock(next, LOCK_EX | LOCK_NB) == -1)+ #expect(errno == EWOULDBLOCK)}@Test("A template folder with unknown files keeps the folder and its lock")