feat: Create backups of configuration when the force option is not used.
This commit is contained in:
@@ -23,6 +23,9 @@ public struct FileClient: Sendable {
|
||||
/// Create a directory at the given location.
|
||||
public var createDirectory: @Sendable (URL) async throws -> Void
|
||||
|
||||
/// Delete the item at the given location.
|
||||
public var delete: @Sendable (URL) async throws -> Void
|
||||
|
||||
/// Check if a file exists at the given location.
|
||||
public var fileExists: @Sendable (URL) -> Bool = { _ in true }
|
||||
|
||||
@@ -57,6 +60,7 @@ extension FileClient: DependencyKey {
|
||||
return .init(
|
||||
copy: { try await manager.copy($0, to: $1) },
|
||||
createDirectory: { try await manager.creatDirectory($0) },
|
||||
delete: { try await manager.delete($0) },
|
||||
fileExists: { manager.fileExists(at: $0) },
|
||||
findVaultFile: { try await manager.findVaultFile(in: $0) },
|
||||
homeDirectory: { manager.homeDirectory() },
|
||||
@@ -79,6 +83,10 @@ struct LiveFileClient: Sendable {
|
||||
try manager.createDirectory(at: url, withIntermediateDirectories: true)
|
||||
}
|
||||
|
||||
func delete(_ url: URL) async throws {
|
||||
try manager.removeItem(at: url)
|
||||
}
|
||||
|
||||
func fileExists(at url: URL) -> Bool {
|
||||
manager.fileExists(atPath: url.cleanFilePath)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user