Skip to content

Commit fef37ec

Browse files
authored
TSCBasic: deprecate localFileSystem setter (#401)
This global should never be mutable, especially when using concurrency.
1 parent 5e1f556 commit fef37ec

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Sources/TSCBasic/FileSystem.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,8 +1162,19 @@ public final class RerootedFileSystemView: FileSystem {
11621162
// `underlyingFileSystem` is required to be `Sendable`.
11631163
extension RerootedFileSystemView: @unchecked Sendable {}
11641164

1165+
private var _localFileSystem: any FileSystem = LocalFileSystem()
1166+
11651167
/// Public access to the local FS proxy.
1166-
public var localFileSystem: FileSystem = LocalFileSystem()
1168+
public var localFileSystem: any FileSystem {
1169+
get {
1170+
return _localFileSystem
1171+
}
1172+
1173+
@available(*, deprecated, message: "This global should never be mutable and is supposed to be read-only. Deprecated in Apr 2023.")
1174+
set {
1175+
_localFileSystem = newValue
1176+
}
1177+
}
11671178

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

0 commit comments

Comments
 (0)