Skip to content

Commit d2394fb

Browse files
committed
call getNode with lock
1 parent e013f97 commit d2394fb

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Sources/TSCBasic/FileSystem.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -841,15 +841,17 @@ public class InMemoryFileSystem: FileSystem {
841841
}
842842

843843
public func withLock<T>(on path: AbsolutePath, type: FileLock.LockType = .exclusive, _ body: () throws -> T) throws -> T {
844-
let resolvedPath: AbsolutePath
844+
let fileQueue: DispatchQueue = try lockFilesLock.withLock {
845845

846-
if case let .symlink(destination) = try getNode(path)?.contents {
847-
resolvedPath = AbsolutePath(destination, relativeTo: path.parentDirectory)
848-
} else {
849-
resolvedPath = path
850-
}
846+
let resolvedPath: AbsolutePath
847+
848+
// FIXME: resolving symlinks is not yet thread safe
849+
if case let .symlink(destination) = try getNode(path)?.contents {
850+
resolvedPath = AbsolutePath(destination, relativeTo: path.parentDirectory)
851+
} else {
852+
resolvedPath = path
853+
}
851854

852-
let fileQueue: DispatchQueue = lockFilesLock.withLock {
853855
if let queueReference = lockFiles[resolvedPath], let queue = queueReference.reference {
854856
return queue
855857
} else {

0 commit comments

Comments
 (0)