Add confirmed project deletion

This commit is contained in:
diyaa
2026-09-15 13:06:27 +02:00
parent bef00b19e1
commit 03bfd3ef75
6 changed files with 133 additions and 14 deletions
@@ -4,6 +4,7 @@ public protocol ProjectStore: Sendable {
func create(_ project: SongProject) async throws
func save(_ project: SongProject) async throws
func open(id: String) async throws -> SongProject
func delete(id: String) async throws
func loadProjectIDs() async throws -> [String]
func loadProjectList() async throws -> [SongProjectListItem]
}
@@ -69,6 +70,14 @@ public actor LocalSongProjectStore: ProjectStore {
return try decoder.decode(SongProject.self, from: data)
}
public func delete(id: String) async throws {
let url = projectURL(for: id)
guard FileManager.default.fileExists(atPath: url.path) else {
throw LocalSongProjectStoreError.projectNotFound(id)
}
try FileManager.default.removeItem(at: url)
}
public func loadProjectIDs() async throws -> [String] {
try await loadProjectList().map(\.id)
}