Skip to content

Commit 6061198

Browse files
authored
FoundationEssentials: limit autosave to user domain (#637)
During the review for the changes to support Windows, we realized that the location that is being used for the autosave information is only available within the user domain mask. The Windows implementation was corrected as part of the implementation, but this corrects the XDG compliant path to reflect this reality.
1 parent 2c35194 commit 6061198

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

Sources/FoundationEssentials/FileManager/SearchPaths/FileManager+XDGSearchPaths.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private enum _XDGUserDirectory: String {
164164

165165
func _XDGSearchPathURL(for directory: FileManager.SearchPathDirectory, in domain: FileManager.SearchPathDomainMask) -> URL? {
166166
return switch (directory, domain) {
167-
case (.autosavedInformationDirectory, _):
167+
case (.autosavedInformationDirectory, .userDomainMask):
168168
_xdgDataHomeURL().appending(component: "Autosave Information", directoryHint: .isDirectory)
169169

170170
case (.desktopDirectory, .userDomainMask):

Tests/FoundationEssentialsTests/FileManager/FileManagerTests.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -797,12 +797,10 @@ final class FileManagerTests : XCTestCase {
797797
let results = fileManager.urls(for: directory, in: domain)
798798
XCTAssertTrue(results.contains(knownURL), "Results \(results.map(\.path)) did not contain known directory \(knownURL.path) for \(directory)/\(domain) while setting the \(key) environment variable", file: file, line: line)
799799
}
800-
800+
801801
validate("XDG_DATA_HOME", suffix: "Autosave Information", directory: .autosavedInformationDirectory, domain: .userDomainMask)
802-
validate("XDG_DATA_HOME", suffix: "Autosave Information", directory: .autosavedInformationDirectory, domain: .localDomainMask)
803802
validate("HOME", suffix: ".local/share/Autosave Information", directory: .autosavedInformationDirectory, domain: .userDomainMask)
804-
validate("HOME", suffix: ".local/share/Autosave Information", directory: .autosavedInformationDirectory, domain: .localDomainMask)
805-
803+
806804
validate("XDG_CACHE_HOME", directory: .cachesDirectory, domain: .userDomainMask)
807805
validate("HOME", suffix: ".cache", directory: .cachesDirectory, domain: .userDomainMask)
808806

0 commit comments

Comments
 (0)