Last active
October 20, 2018 10:09
-
-
Save laevandus/1552c639290a439a1927439c94efea8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func removeData(forIdentifier identifier: Identifier) { | |
queue.async(flags: .barrier) { | |
let url = self.url(forIdentifier: identifier) | |
guard FileManager.default.fileExists(atPath: url.path) else { return } | |
do { | |
try FileManager.default.removeItem(at: url) | |
} | |
catch { | |
print("Failed removing file at URL \(url) with error \(error).") | |
} | |
} | |
} | |
func removeAll() { | |
queue.async(flags: .barrier) { | |
do { | |
let urls = try FileManager.default.contentsOfDirectory(at: self.dataStoreURL, includingPropertiesForKeys: nil, options: []) | |
try urls.forEach({ try FileManager.default.removeItem(at: $0) }) | |
} | |
catch { | |
print("Failed removing all files with error \(error).") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment