From fef37ecc78f58f459982bc247d47cd05790e29c5 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Sat, 15 Apr 2023 10:25:28 +0100 Subject: [PATCH] TSCBasic: deprecate `localFileSystem` setter (#401) This global should never be mutable, especially when using concurrency. --- Sources/TSCBasic/FileSystem.swift | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Sources/TSCBasic/FileSystem.swift b/Sources/TSCBasic/FileSystem.swift index c11fad16..9184e27d 100644 --- a/Sources/TSCBasic/FileSystem.swift +++ b/Sources/TSCBasic/FileSystem.swift @@ -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 {}