Create intermediate cache directories

This commit is contained in:
Nindi Gill 2022-07-01 20:29:18 +10:00
parent 531068629d
commit 7ae18dfbf6
2 changed files with 5 additions and 4 deletions

View file

@ -13,11 +13,12 @@ struct DirectoryCreator {
/// Create a directory at the provided URL.
///
/// - Parameters:
/// - url: The URL of the directory to create.
/// - url: The URL of the directory to create.
/// - withIntermediateDirectories: Set to `true` to create all intermediate directories.
///
/// - Throws: An `Error` if the command failed to execute.
static func create(_ url: URL) async throws {
static func create(_ url: URL, withIntermediateDirectories: Bool = false) async throws {
try await DirectoryRemover.remove(url)
try FileManager.default.createDirectory(at: url, withIntermediateDirectories: false, attributes: nil)
try FileManager.default.createDirectory(at: url, withIntermediateDirectories: withIntermediateDirectories, attributes: nil)
}
}

View file

@ -216,7 +216,7 @@ class TaskManager: ObservableObject {
if !FileManager.default.fileExists(atPath: cacheDirectoryURL.path) {
tasks += [
MistTask(type: .configure, description: "cache directory") {
try await DirectoryCreator.create(cacheDirectoryURL)
try await DirectoryCreator.create(cacheDirectoryURL, withIntermediateDirectories: true)
}
]
}