File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -552,7 +552,7 @@ public class InMemoryFileSystem: FileSystem {
552552 /// reality, the only practical use for InMemoryFileSystem is for unit
553553 /// tests.
554554 private let lock = Lock ( )
555-
555+ /// Exclusive file system lock vended to clients through `withLock()`.
556556 private var lockFiles = Dictionary < AbsolutePath , WeakReference < DispatchQueue > > ( )
557557 /// Used to access lockFiles in a thread safe manner.
558558 private let lockFilesLock = Lock ( )
@@ -906,17 +906,15 @@ public class InMemoryFileSystem: FileSystem {
906906 }
907907
908908 public func withLock< T> ( on path: AbsolutePath , type: FileLock . LockType = . exclusive, _ body: ( ) throws -> T ) throws -> T {
909- let fileQueue : DispatchQueue = try lockFilesLock. withLock {
910-
911- let resolvedPath : AbsolutePath
912-
913- // FIXME: resolving symlinks is not yet thread safe
909+ let resolvedPath : AbsolutePath = try lock. withLock {
914910 if case let . symlink( destination) = try getNode ( path) ? . contents {
915- resolvedPath = AbsolutePath ( destination, relativeTo: path. parentDirectory)
911+ return AbsolutePath ( destination, relativeTo: path. parentDirectory)
916912 } else {
917- resolvedPath = path
913+ return path
918914 }
915+ }
919916
917+ let fileQueue : DispatchQueue = lockFilesLock. withLock {
920918 if let queueReference = lockFiles [ resolvedPath] , let queue = queueReference. reference {
921919 return queue
922920 } else {
You can’t perform that action at this time.
0 commit comments