Bugfixes aus dem Projekt-Review (27 Punkte)

Datenverlust:
- Ingest löscht keine vorhandenen Fotos mehr: gleiche Namen (zweiter Body/zweite Karte) bekommen -1, -2 …
- Ingest-Vorlage nur auf die neu kopierten Fotos, nicht auf den ganzen Ordner
- Neue Dateien brechen das Laden der Metadaten nicht mehr ab
- Code-Dateien in Windows-1252/Mac Roman werden nicht mehr als UTF-16-Zeichensalat gelesen
- Code-Bibliothek und Teams werden tolerant gelesen (fehlende Felder löschen nichts mehr)
- IPTC-Fenster speichert offene Änderungen, wenn das Bild von außen gewechselt wird
- Datum mit Uhrzeit bleibt beim Speichern erhalten; Lightroom-„abgelehnt“ (-1) bleibt erhalten
- gesperrte Fotos: beim Ingest nur getaggt, Sterne aus der Kamera bleiben

Zuverlässigkeit:
- exiftool-Fehlermeldungen werden sicher erkannt (Marker auf stderr statt 5 ms warten)
- ein defektes Bild kostet nicht mehr 49 andere ihre Metadaten
- LR-Export: Upload/IPTC auch nach Ordnerwechsel, Zeitlimit für Jobs ohne Antwort
- Trikot-Erkennung bleibt beim Ordnerwechsel beim richtigen Ordner; nach Ingest mit den neuen Fotos
- Absturz beim Löschen eines FTP-Servers behoben
- doppelte Namen beim FTP-Umbenennen werden nummeriert; Wiederholen öffnet die Aufgabe wieder
- Vorschau-Cache beachtet die angeforderte Größe (echte 100 %-Ansicht)
- Ingest: Verlauf auch bei Abbruch gespeichert, keine Lücken in der Laufnummer
- Auswerfen schließt keine Tabs anderer Karten; eigener exiftool-Pfad hat Vorrang

Tempo: Massenänderungen sortieren die Liste einmal statt pro Bild, Einstellungen werden verzögert gespeichert.
Tests für Namenskollision, Kodierung, tolerante Code-Bibliothek und Datum mit Uhrzeit.

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-05 08:08:06 +00:00
1 parent dd022b6900
commit 1f63714b73
12 files changed
+299 -56

No files matched your search

@@ -193,6 +193,8 @@ public enum IngestService {
let destRoots = [settings.primaryDestination] + (settings.secondaryEnabled && !settings.backupDestination.isEmpty ? [settings.backupDestination] : [])
progress(IngestProgress(done: 0, total: total, currentFile: "Starte …"))
// also after a cancel/error: what was copied is not copied again next time
defer { if settings.incremental { saveHistory(history) } }
for e in entries {
try Task.checkCancellation()
let item = e.item
@@ -204,7 +206,6 @@ public enum IngestService {
if settings.renameEnabled, !settings.renamePattern.isEmpty {
baseName = VariableExpander.expand(settings.renamePattern, context: ctx).replacingOccurrences(of: "/", with: "-")
}
if settings.sequenceEnabled { seq += 1 }
// Card structure (DCIM/100NZ8_1) below the destination if requested
let rel = settings.preserveStructure
? item.primary.deletingLastPathComponent().path.replacingOccurrences(of: e.root.path, with: "")
@@ -218,9 +219,24 @@ public enum IngestService {
case .nonRawOnly: rawFiles = rawFiles.filter { !FileKind(url: $0).isRawLike }
}
guard !rawFiles.isEmpty else { continue }
if settings.sequenceEnabled { seq += 1 } // only photos that are really copied get a number
var files = rawFiles
if item.kind.usesSidecar, fm.fileExists(atPath: item.sidecarURL.path), rawFiles.contains(item.primary) { files.append(item.sidecarURL) }
// Name for this photo in every destination: an existing file is never deleted. Same name + same size
// = already copied (skip); same name, other photo (second body, second card) → "-1", "-2" …
var targetName = baseName
var skipGroup = false
if let primaryFolder = destRoots.first.map({ root -> URL in
var f = URL(fileURLWithPath: root)
if !sub.isEmpty { f.appendPathComponent(sub, isDirectory: true) }
if !rel.isEmpty { f.appendPathComponent(rel, isDirectory: true) }
return f
}) {
(targetName, skipGroup) = uniqueName(baseName, files: files, in: primaryFolder,
skipDuplicates: settings.skipDuplicates)
}
for destRoot in destRoots {
var folder = URL(fileURLWithPath: destRoot)
if !sub.isEmpty { folder.appendPathComponent(sub, isDirectory: true) }
@@ -229,10 +245,11 @@ public enum IngestService {
let isPrimary = destRoot == settings.primaryDestination
if isPrimary, usedFolders.insert(folder).inserted { onFolder?(folder) }
for (n, src) in files.enumerated() {
let dest = folder.appendingPathComponent(baseName).appendingPathExtension(src.pathExtension)
if fm.fileExists(atPath: dest.path) {
if settings.skipDuplicates, sameSize(src, dest) { continue }
try fm.removeItem(at: dest)
let dest = folder.appendingPathComponent(targetName).appendingPathExtension(src.pathExtension)
if skipGroup || fm.fileExists(atPath: dest.path) {
// already there (duplicate, or the backup already has it) – never overwrite
if isPrimary, n == 0, src.pathExtension.lowercased() != "xmp" { done += 1 }
continue
}
try copy(src, to: dest)
if isPrimary {
@@ -249,7 +266,6 @@ public enum IngestService {
}
if settings.incremental { history.insert(historyKey(item.primary)) }
}
if settings.incremental { saveHistory(history) }
return IngestResult(folders: Array(usedFolders).sorted { $0.path < $1.path }, copied: copied,
lockedCopies: lockedCopies, nextSequence: seq, skipped: skipped)
}
@@ -270,6 +286,21 @@ public enum IngestService {
return last.isEmpty ? "diskutil eject fehlgeschlagen" : last
}
/// Base name that collides with no other photo in `folder`. If the photo itself is already there
/// (same name and size of its main file) and duplicates are skipped, `skip` is true.
static func uniqueName(_ base: String, files: [URL], in folder: URL, skipDuplicates: Bool) -> (name: String, skip: Bool) {
let fm = FileManager.default
func dest(_ name: String, _ src: URL) -> URL { folder.appendingPathComponent(name).appendingPathExtension(src.pathExtension) }
if let main = files.first, fm.fileExists(atPath: dest(base, main).path) {
if skipDuplicates, sameSize(main, dest(base, main)) { return (base, true) }
} else if !files.contains(where: { fm.fileExists(atPath: dest(base, $0).path) }) {
return (base, false)
}
var n = 1
while files.contains(where: { fm.fileExists(atPath: dest("\(base)-\(n)", $0).path) }) { n += 1 }
return ("\(base)-\(n)", false)
}
static func sameSize(_ a: URL, _ b: URL) -> Bool {
func size(_ u: URL) -> Int64? {
guard let attrs = try? FileManager.default.attributesOfItem(atPath: u.path) else { return nil }