Skip to content

Commit 40e539d

Browse files
committed
feat: Allow for setting the excludedPathsList key to an array of paths (strings) that can be appended to the urlExclusionsList property.
Signed-off-by: ryan-alectrona <[email protected]>
1 parent 5936b6b commit 40e539d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Diff for: migrator/AppContext.swift

+12-4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ struct AppContext {
7070
/// UserDefaults key indicating which policy to use fo handle duplicate files on the destination device.
7171
private static let duplicateFilesHandlingPolicyKey: String = "duplicateFilesHandlingPolicy"
7272

73+
/// UserDefaults key indicating the list of paths to exclude during file discovery
74+
private static let excludedPathsListKey: String = "excludedPathsList"
75+
7376
/// UserDefaults key indicating whether the app should skip the device reboot step after migration.
7477
static let skipRebootUserDefaultsKey: String = "skipDeviceReboot"
7578

@@ -105,11 +108,16 @@ struct AppContext {
105108
static var duplicateFilesHandlingPolice: DuplicateFilesHandlingPolicy {
106109
return DuplicateFilesHandlingPolicy(rawValue: UserDefaults.standard.string(forKey: Self.duplicateFilesHandlingPolicyKey) ?? "overwrite") ?? .overwrite
107110
}
108-
111+
static var urlExclusionsList: [URL?] {
112+
let managedExcludedPaths = UserDefaults.standard.array(forKey: Self.excludedPathsListKey) as? [String] ?? []
113+
let managedExcludedURLs = managedExcludedPaths.compactMap { URL(string: $0) }
114+
return managedExcludedURLs + defaultUrlExclusionList
115+
}
116+
109117
// MARK: - File Scan Variables
110-
111-
/// Custom list of paths tha needs to be ignored during file discovery.
112-
static var urlExclusionList: [URL?] = [FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask).first,
118+
119+
/// Custom list of paths that needs to be ignored during file discovery.
120+
static var defaultUrlExclusionList: [URL?] = [FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask).first,
113121
FileManager.default.urls(for: .applicationDirectory, in: .localDomainMask).first?.appendingPathComponent("\(Bundle.main.name).app"),
114122
FileManager.default.urls(for: .applicationDirectory, in: .localDomainMask).first?.appendingPathComponent("Numbers.app"),
115123
FileManager.default.urls(for: .applicationDirectory, in: .localDomainMask).first?.appendingPathComponent("Pages.app"),

0 commit comments

Comments
 (0)