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:
1 parent
dd022b6900
commit
1f63714b73
12 files changed
+299
-56
No files matched your search
@@ -19,11 +19,14 @@ public final class ExifTool: @unchecked Sendable {
|
||||
public static let searchPaths = ["/opt/homebrew/bin/exiftool", "/usr/local/bin/exiftool", "/usr/bin/exiftool"]
|
||||
|
||||
public static func locate(custom: String? = nil) -> URL? {
|
||||
let candidates = [custom].compactMap { $0 }.filter { !$0.isEmpty } + searchPaths
|
||||
// the path set in Settings first, then a bundled copy, then the usual install locations
|
||||
if let custom, !custom.isEmpty, FileManager.default.isExecutableFile(atPath: custom) {
|
||||
return URL(fileURLWithPath: custom)
|
||||
}
|
||||
if let bundled = Bundle.main.url(forResource: "exiftool", withExtension: nil, subdirectory: "exiftool") {
|
||||
return bundled
|
||||
}
|
||||
return candidates.map { URL(fileURLWithPath: $0) }.first { FileManager.default.isExecutableFile(atPath: $0.path) }
|
||||
return searchPaths.map { URL(fileURLWithPath: $0) }.first { FileManager.default.isExecutableFile(atPath: $0.path) }
|
||||
}
|
||||
|
||||
private let executable: URL
|
||||
@@ -87,7 +90,10 @@ public final class ExifTool: @unchecked Sendable {
|
||||
counter += 1
|
||||
let marker = "{ready\(counter)}"
|
||||
stderrLock.lock(); stderrBuffer.removeAll(); stderrLock.unlock()
|
||||
let payload = (args.map { $0.replacingOccurrences(of: "\n", with: " ") } + ["-execute\(counter)"]).joined(separator: "\n") + "\n"
|
||||
// -echo4 prints the marker on stderr after the command finished → all its messages are in the buffer
|
||||
let errMarker = "{done\(counter)}"
|
||||
let payload = (args.map { $0.replacingOccurrences(of: "\n", with: " ") } + ["-echo4", errMarker, "-execute\(counter)"])
|
||||
.joined(separator: "\n") + "\n"
|
||||
try stdin.write(contentsOf: Data(payload.utf8))
|
||||
var out = Data()
|
||||
let markerData = Data(marker.utf8)
|
||||
@@ -100,10 +106,20 @@ public final class ExifTool: @unchecked Sendable {
|
||||
break
|
||||
}
|
||||
}
|
||||
// stderr arrives asynchronously; give it a moment.
|
||||
Thread.sleep(forTimeInterval: 0.005)
|
||||
stderrLock.lock(); let err = String(decoding: stderrBuffer, as: UTF8.self); stderrLock.unlock()
|
||||
return (String(decoding: out, as: UTF8.self), err)
|
||||
// stderr arrives asynchronously: wait for our marker (max. 5 s)
|
||||
let errMarkerData = Data(errMarker.utf8)
|
||||
var err = ""
|
||||
let deadline = Date().addingTimeInterval(5)
|
||||
while true {
|
||||
stderrLock.lock(); let buf = stderrBuffer; stderrLock.unlock()
|
||||
if let r = buf.range(of: errMarkerData) {
|
||||
err = String(decoding: buf[buf.startIndex..<r.lowerBound], as: UTF8.self)
|
||||
break
|
||||
}
|
||||
if Date() > deadline { err = String(decoding: buf, as: UTF8.self); break }
|
||||
Thread.sleep(forTimeInterval: 0.002)
|
||||
}
|
||||
return (String(decoding: out, as: UTF8.self), err.trimmingCharacters(in: .whitespacesAndNewlines))
|
||||
}
|
||||
|
||||
/// Writes a (possibly multi-line) value to a temp file so it can be passed as `-TAG<=file`.
|
||||
@@ -229,7 +245,14 @@ public final class ExifToolPool: @unchecked Sendable {
|
||||
let mine = chunks.enumerated().filter { $0.offset % workers.count == w }.map(\.element)
|
||||
group.addTask {
|
||||
for chunk in mine {
|
||||
if let meta = try? await worker.readMetadata(files: chunk) { await onChunk(meta) }
|
||||
if let meta = try? await worker.readMetadata(files: chunk) {
|
||||
await onChunk(meta)
|
||||
} else {
|
||||
// one broken file must not cost the other 49 their metadata → file by file
|
||||
for file in chunk {
|
||||
if let meta = try? await worker.readMetadata(files: [file]) { await onChunk(meta) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user