IPTC-Info- und Aufgaben-Fenster wie PM, Ingest im Hintergrund + Karten-Erkennung, ⌘E Lightroom, RAW/SENT-Workflow, schnellere Auswahl, Zahlen = Sterne
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
42ab9c9361
commit
d100249c12
18 files changed
+977
-213
No files matched your search
@@ -0,0 +1,62 @@
|
||||
import AppKit
|
||||
import Foundation
|
||||
|
||||
/// Watches a folder for added/removed files (e.g. Lightroom exporting into SENT, live ingest).
|
||||
final class FolderWatcher {
|
||||
private var source: DispatchSourceFileSystemObject?
|
||||
private var fd: Int32 = -1
|
||||
private var pending: DispatchWorkItem?
|
||||
private let onChange: () -> Void
|
||||
|
||||
init(onChange: @escaping () -> Void) { self.onChange = onChange }
|
||||
|
||||
func watch(_ url: URL?) {
|
||||
stop()
|
||||
guard let url else { return }
|
||||
fd = open(url.path, O_EVTONLY)
|
||||
guard fd >= 0 else { return }
|
||||
let src = DispatchSource.makeFileSystemObjectSource(fileDescriptor: fd, eventMask: [.write, .rename, .delete], queue: .main)
|
||||
src.setEventHandler { [weak self] in self?.scheduleChange() }
|
||||
let descriptor = fd
|
||||
src.setCancelHandler { close(descriptor) }
|
||||
src.resume()
|
||||
source = src
|
||||
}
|
||||
|
||||
/// Debounced: many files arrive at once during ingest/export.
|
||||
private func scheduleChange() {
|
||||
pending?.cancel()
|
||||
let item = DispatchWorkItem { [weak self] in self?.onChange() }
|
||||
pending = item
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.6, execute: item)
|
||||
}
|
||||
|
||||
func stop() {
|
||||
pending?.cancel()
|
||||
source?.cancel()
|
||||
source = nil
|
||||
fd = -1
|
||||
}
|
||||
|
||||
deinit { stop() }
|
||||
}
|
||||
|
||||
/// Opens the ingest window when a memory card (volume with DCIM) is mounted.
|
||||
final class CardMonitor {
|
||||
private var observer: NSObjectProtocol?
|
||||
|
||||
func start(onCard: @escaping (URL) -> Void) {
|
||||
guard observer == nil else { return }
|
||||
observer = NSWorkspace.shared.notificationCenter.addObserver(
|
||||
forName: NSWorkspace.didMountNotification, object: nil, queue: .main
|
||||
) { note in
|
||||
guard let vol = note.userInfo?[NSWorkspace.volumeURLUserInfoKey] as? URL else { return }
|
||||
let dcim = vol.appendingPathComponent("DCIM")
|
||||
if FileManager.default.fileExists(atPath: dcim.path) { onCard(dcim) }
|
||||
}
|
||||
}
|
||||
|
||||
deinit {
|
||||
if let observer { NSWorkspace.shared.notificationCenter.removeObserver(observer) }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user