Skip to content

Commit 7496db3

Browse files
committed
fix(runtime): replace unreliable replaceItemAt with removeItem+moveItem on Linux
FileManager.replaceItemAt is unreliable on Linux's swift-corelibs-foundation, silently failing to place the replacement file and leaving the original path empty. This caused the StoreFlushService round-trip test to crash in CI.
1 parent 09b048f commit 7496db3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Sources/ARORuntime/Store/StoreFlushService.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ public actor StoreFlushService {
8080
}
8181
#endif
8282

83-
// Atomic rename
84-
_ = try fm.replaceItemAt(filePath, withItemAt: tmpURL)
83+
// Atomic rename (avoid replaceItemAt which is unreliable on Linux)
84+
try fm.removeItem(at: filePath)
85+
try fm.moveItem(at: tmpURL, to: filePath)
8586
} catch {
8687
// Clean up temp file on failure
8788
try? FileManager.default.removeItem(at: tmpURL)
@@ -119,7 +120,8 @@ public actor StoreFlushService {
119120
}
120121
#endif
121122

122-
_ = try FileManager.default.replaceItemAt(filePath, withItemAt: tmpURL)
123+
try FileManager.default.removeItem(at: filePath)
124+
try FileManager.default.moveItem(at: tmpURL, to: filePath)
123125
} catch {
124126
try? FileManager.default.removeItem(at: tmpURL)
125127
}

0 commit comments

Comments
 (0)