Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/engine/src/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Unit {
pub struct TaskInfo {
pub id: u64,
/// A stable id: `import`, `export`, `scan`, `previews`, `smartPreviews`, `lightroom`, `merge`, `download`,
/// `faces`, `denoise`, `findMissing`, `applePhotos`, `cache`, `focus`.
/// `faces`, `denoise`, `findMissing`, `applePhotos`, `cache`, `focus`, `saveMetadata`, `readMetadata`.
pub kind: &'static str,
/// English; the frontend translates it.
pub label: String,
Expand Down
2 changes: 2 additions & 0 deletions crates/engine/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mod face_models;
mod face_recognize;
pub mod filters;
mod focus;
pub mod folder_metadata;
pub mod geocode;
pub mod keywords;
pub mod library;
Expand Down Expand Up @@ -177,6 +178,7 @@ pub fn command_specs() -> &'static [CommandSpec] {
v.extend(face_detect::specs());
v.extend(face_recognize::specs());
v.extend(focus::specs());
v.extend(folder_metadata::specs());
v.extend(activity::specs());
v
})
Expand Down
357 changes: 357 additions & 0 deletions crates/engine/src/cmd/folder_metadata.rs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions crates/engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ pub struct Session {
/// Set by a command whose change must not rewrite the photo's XMP sidecar even with auto-write on
/// (a catalog-only edit of data the sidecar writer does not emit); consumed when the command ends.
pub(crate) skip_auto_write: bool,
/// The folder metadata save or read waiting for `folder.metadataPump` ([`cmd::folder_metadata`]); dropped when another library opens.
pub(crate) folder_metadata: Option<cmd::folder_metadata::FolderMetadataJob>,
/// The order of Reload from Disk runs, so an older one finishing late is dropped ([`cmd::reload`]).
pub(crate) reload_tickets: cmd::reload::Tickets,
/// Photos whose automatic XMP sidecar write failed (their folder offline, read-only or full), written again by
Expand Down Expand Up @@ -471,6 +473,7 @@ impl Session {
pending_sidecar_repairs: Vec::new(),
interaction: None,
skip_auto_write: false,
folder_metadata: None,
reload_tickets: Default::default(),
unsaved_sidecars: Default::default(),
denoise: Default::default(),
Expand Down
3 changes: 2 additions & 1 deletion crates/engine/src/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ impl Session {
{
log::error!("library: {e}");
}
// Photo ids belong to one library; denoise work must not carry into the next.
// Photo ids belong to one library; a folder's metadata job and denoise work must not carry into the next.
self.folder_metadata = None;
self.denoise.library_changed();
self.media.denoise.clear();
// what was learned about the old library's faces is saved, and none of it carries over (photo ids are per library)
Expand Down
12 changes: 11 additions & 1 deletion crates/engine/src/sidecar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,9 +828,19 @@ impl Session {

/// Like [`Session::read_sidecar_op`], retaining transient diagnostics for the command report.
pub fn read_sidecar_op_with_warnings(&self, id: PhotoId) -> Result<Option<(Op, PathBuf, Vec<crate::import::ImportWarning>)>> {
self.read_sidecar_op_named(id, self.sidecar_naming(id))
}

/// [`Session::read_sidecar_op_with_warnings`] with the sidecar naming already worked out ([`StemOwners::naming`]): a
/// folder of photos knows its owners once, instead of one pass over the catalog per photo.
pub(crate) fn read_sidecar_op_named(
&self,
id: PhotoId,
naming: SidecarNaming,
) -> Result<Option<(Op, PathBuf, Vec<crate::import::ImportWarning>)>> {
let p = self.catalog.photo(id).ok_or(lightcraft_catalog::CatalogError::NoPhoto(id))?;
let Some(orig) = file_path(p) else { return Ok(None) };
let Some((packet, from)) = read_packet(orig, p.kind, self.sidecar_naming(id)) else { return Ok(None) };
let Some((packet, from)) = read_packet(orig, p.kind, naming) else { return Ok(None) };
let sc = parse_sidecar(&packet, crate::crs::Target::for_photo(p)).map_err(|e| EngineError::Other(format!("{}: {e}", from.display())))?;
let mut warnings = sc.warnings.clone();
for warning in &mut warnings {
Expand Down
2 changes: 2 additions & 0 deletions crates/engine/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ mod face_tiles;
mod filesystem_history;
#[cfg(all(test, not(target_arch = "wasm32")))]
mod focus_scan;
#[cfg(all(test, not(target_arch = "wasm32")))]
mod folder_metadata;
mod folders;
mod forget_local;
mod history_cursor;
Expand Down
Loading
Loading