Skip to content

Commit 885218a

Browse files
committed
Fix potential crash in repository cache fallback
It is possible that copying from the cache fails mid-way which can lead to SwiftPM hitting a precondition in the fallback. We should clear any potential leftover data before doing the fallback. rdar://73505115
1 parent 629064c commit 885218a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Sources/SourceControl/RepositoryManager.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ public class RepositoryManager {
384384
} catch {
385385
// Fetch without populating the cache in the case of an error.
386386
print("Skipping cache due to an error: \(error)")
387+
// It is possible that we already created the directory before failing, so clear leftover data if present.
388+
try fileSystem.removeFileTree(repositoryPath)
387389
try self.provider.fetch(repository: handle.repository, to: repositoryPath)
388390
fromCache = false
389391
}

0 commit comments

Comments
 (0)