Ingest: bei zu wenig Speicherplatz abbrechen

- vor dem Kopieren: Platzbedarf pro Ziel-Volume (Haupt + Backup auf derselben Platte doppelt)
  plus 2 GB Reserve geprüft – reicht es nicht, startet der Ingest gar nicht erst
- während des Ingests: vor jedem Foto erneut geprüft (Platte kann sich auch anders füllen)
- volle Platte beim Kopieren: halbe Datei wird entfernt, klare Meldung, Karte wird nicht ausgeworfen,
  bis dahin kopierte Fotos sind vollständig und stehen im Verlauf

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D
This commit is contained in:
Lichtkasten DevandClaude Opus 5.5 committed 2026-11-06 23:55:04 +00:00
1 parent b2210757dd
commit b9d7ea3146
3 files changed
+93 -1

No files matched your search

@@ -105,3 +105,20 @@ final class IngestRecoveryTests: XCTestCase {
exiftool: ExifTool(executable: exe), historyFile: history) { _ in }
}
}
final class IngestSpaceTests: XCTestCase {
func testRefusesWhenDestinationIsTooSmall() throws {
let dir = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
defer { try? FileManager.default.removeItem(at: dir) }
let free = try XCTUnwrap(IngestService.freeBytes(dir))
// a sparse "card file" larger than the free space of the destination
let big = dir.appendingPathComponent("big.NEF")
FileManager.default.createFile(atPath: big.path, contents: nil)
let h = try FileHandle(forWritingTo: big)
try h.truncate(atOffset: UInt64(free) + 1)
try h.close()
XCTAssertThrowsError(try IngestService.checkFreeSpace(entriesFiles: [[big]], destRoots: [dir.appendingPathComponent("INPUT")]))
XCTAssertNoThrow(try IngestService.checkFreeSpace(entriesFiles: [], destRoots: [dir]))
}
}