mirror of
https://github.com/ninxsoft/Mist.git
synced 2025-05-21 18:55:24 -04:00
Create intermediate cache directories
This commit is contained in:
parent
531068629d
commit
7ae18dfbf6
2 changed files with 5 additions and 4 deletions
|
@ -14,10 +14,11 @@ struct DirectoryCreator {
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - 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.
|
/// - 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 await DirectoryRemover.remove(url)
|
||||||
try FileManager.default.createDirectory(at: url, withIntermediateDirectories: false, attributes: nil)
|
try FileManager.default.createDirectory(at: url, withIntermediateDirectories: withIntermediateDirectories, attributes: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,7 @@ class TaskManager: ObservableObject {
|
||||||
if !FileManager.default.fileExists(atPath: cacheDirectoryURL.path) {
|
if !FileManager.default.fileExists(atPath: cacheDirectoryURL.path) {
|
||||||
tasks += [
|
tasks += [
|
||||||
MistTask(type: .configure, description: "cache directory") {
|
MistTask(type: .configure, description: "cache directory") {
|
||||||
try await DirectoryCreator.create(cacheDirectoryURL)
|
try await DirectoryCreator.create(cacheDirectoryURL, withIntermediateDirectories: true)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue