Skip to content

Commit

Permalink
TSCBasic: deprecate localFileSystem setter (#401)
Browse files Browse the repository at this point in the history
This global should never be mutable, especially when using concurrency.
  • Loading branch information
MaxDesiatov authored Apr 15, 2023
1 parent 5e1f556 commit fef37ec
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Sources/TSCBasic/FileSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1162,8 +1162,19 @@ public final class RerootedFileSystemView: FileSystem {
// `underlyingFileSystem` is required to be `Sendable`.
extension RerootedFileSystemView: @unchecked Sendable {}

private var _localFileSystem: any FileSystem = LocalFileSystem()

/// Public access to the local FS proxy.
public var localFileSystem: FileSystem = LocalFileSystem()
public var localFileSystem: any FileSystem {
get {
return _localFileSystem
}

@available(*, deprecated, message: "This global should never be mutable and is supposed to be read-only. Deprecated in Apr 2023.")
set {
_localFileSystem = newValue
}
}

// `LocalFileSystem` doesn't hold any internal state and all of its underlying operations are blocking.
extension LocalFileSystem: @unchecked Sendable {}
Expand Down

0 comments on commit fef37ec

Please sign in to comment.