improvements on the ui

This commit is contained in:
2026-11-25 07:14:49 +01:00
parent 3afdb6d67f
commit b7c72b9e16
249 changed files with 19702 additions and 17358 deletions
@@ -85,6 +85,40 @@ import UniformTypeIdentifiers
let name = ImageStore(base: base).name(ext: "webp")
#expect(name.wholeMatch(of: /\d{4}-\d{2}-\d{2}-\d{6}-[0-9a-f]{4}\.webp/) != nil)
}
@Test("an image file no image line uses is deleted, a used one stays")
func removeUnused() throws {
let images = store()
try FileManager.default.createDirectory(at: images.folder, withIntermediateDirectories: true)
let png = try imageData(.png)
try png.write(to: images.folder.appendingPathComponent("used.png"))
try png.write(to: images.folder.appendingPathComponent("unused.png"))
#expect(images.removeUnused(keeping: ["images/used.png"]) == ["images/unused.png"])
#expect(FileManager.default.fileExists(atPath: images.folder.appendingPathComponent("used.png").path))
#expect(!FileManager.default.fileExists(atPath: images.folder.appendingPathComponent("unused.png").path))
}
@Test("a symbolic link, a hidden file and a file that is no image stay, and so does the file a link points to")
func removeUnusedTouchesOnlyImageFiles() throws {
let images = store()
let manager = FileManager.default
try manager.createDirectory(at: images.folder, withIntermediateDirectories: true)
let outside = base.appendingPathComponent("outside.png")
try imageData(.png).write(to: outside)
try manager.createSymbolicLink(at: images.folder.appendingPathComponent("link.png"), withDestinationURL: outside)
try Data().write(to: images.folder.appendingPathComponent(".hidden.png"))
try Data().write(to: images.folder.appendingPathComponent("notes.txt"))
#expect(images.removeUnused(keeping: []).isEmpty)
#expect(manager.fileExists(atPath: outside.path))
#expect((try? manager.destinationOfSymbolicLink(atPath: images.folder.appendingPathComponent("link.png").path)) != nil)
#expect(manager.fileExists(atPath: images.folder.appendingPathComponent(".hidden.png").path))
#expect(manager.fileExists(atPath: images.folder.appendingPathComponent("notes.txt").path))
}
@Test("a missing image folder deletes nothing")
func removeUnusedWithoutFolder() {
#expect(store().removeUnused(keeping: []).isEmpty)
}
}
private final class Counter: @unchecked Sendable {