Skip to content

Commit 401e679

Browse files
authored
fix potential race in the computation of cache state (#3711)
motivation: fix unstable test changes: compute the cache state before queueing the delegate call, since otherwise it may compute the state after the cache has been created
1 parent 603d7ee commit 401e679

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/SourceControl/RepositoryManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ public class RepositoryManager {
169169
handle.status = .pending
170170
// Make sure destination is free.
171171
try? self.fileSystem.removeFileTree(repositoryPath)
172-
172+
let isCached = self.cachePath.map{ self.fileSystem.exists($0.appending(handle.subpath)) } ?? false
173+
173174
// Inform delegate.
174175
queue.async {
175-
let isCached = self.cachePath.map{ self.fileSystem.exists($0.appending(handle.subpath)) } ?? false
176176
let details = FetchDetails(fromCache: isCached, updatedCache: false)
177177
self.delegate?.fetchingWillBegin(handle: handle, fetchDetails: details)
178178
}

0 commit comments

Comments
 (0)