Repository navigation
LRC-LIB-CATALOG-IMPORT: captions come from Lightroom's AgLibraryIPTC table too (#4043) #4293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ec6b879
cf4027b
4c596ee
e3df1c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -210,6 +210,10 @@ pub struct CatalogPhoto { | |
| pub keywords: Vec<String>, | ||
| pub history: Vec<Row>, | ||
| pub snapshots: Vec<Row>, | ||
| /// The caption Lightroom shows, from its `AgLibraryIPTC` table: it can be missing from the cached XMP packet | ||
| /// ([`CatalogPhoto::xmp`]) Lightroom keeps for the image (issue #4043). Empty when the table has none. | ||
| #[serde(default)] | ||
| pub caption: String, | ||
| /// Whether `path` may be looked at (derived when the catalog is read; not archived). | ||
| #[serde(skip)] | ||
| pub original: Original, | ||
|
|
@@ -504,8 +508,9 @@ pub fn read_source( | |
| total: &AtomicUsize, | ||
| done: &AtomicUsize, | ||
| ) -> Result<CatalogImport, String> { | ||
| // 13 catalog tables plus one validation stage; ImportJob adds one unit per original path. | ||
| total.store(14, Ordering::Relaxed); | ||
| // 13 catalog tables, the optional IPTC table (captions, #4043) and one validation stage; ImportJob adds one unit | ||
| // per original path. | ||
| total.store(15, Ordering::Relaxed); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Count the validation stage as completed. A successful
|
||
| done.store(0, Ordering::Relaxed); | ||
| ensure_read_active(cancel)?; | ||
| if crate::lightroom_backup::is_backup(path) { | ||
|
|
@@ -562,6 +567,12 @@ fn read_file(path: &Path, document: &Path, source: &Path, cancel: &AtomicBool, d | |
| let roots: HashMap<_, _> = table("AgLibraryRootFolder", true, &mut warnings)?.into_iter().map(|r| (number(&r, "id_local"), r)).collect(); | ||
| let folders: HashMap<_, _> = table("AgLibraryFolder", true, &mut warnings)?.into_iter().map(|r| (number(&r, "id_local"), r)).collect(); | ||
| let files: HashMap<_, _> = table("AgLibraryFile", true, &mut warnings)?.into_iter().map(|r| (number(&r, "id_local"), r)).collect(); | ||
| // the caption each image has in Lightroom's own IPTC table (the cached XMP below may not restate it) | ||
| let mut captions: HashMap<_, _> = optional_table("AgLibraryIPTC", &mut warnings)? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Warn when the IPTC table is missing. When
|
||
| .into_iter() | ||
| .filter(|r| !text(r, "caption").trim().is_empty()) | ||
| .map(|r| (number(&r, "image"), text(&r, "caption").to_string())) | ||
| .collect(); | ||
| let develops: HashMap<_, _> = optional_table("Adobe_imageDevelopSettings", &mut warnings)? | ||
| .into_iter() | ||
| .map(|r| (number(&r, "image"), text(&r, "text").to_string())) | ||
|
|
@@ -693,6 +704,7 @@ fn read_file(path: &Path, document: &Path, source: &Path, cancel: &AtomicBool, d | |
| keywords: keywords.remove(&id).unwrap_or_default(), | ||
| history: history.remove(&id).unwrap_or_default(), | ||
| snapshots: snapshots.remove(&id).unwrap_or_default(), | ||
| caption: captions.remove(&id).unwrap_or_default(), | ||
| original, | ||
| }); | ||
| } | ||
|
|
@@ -1404,6 +1416,10 @@ pub(crate) fn apply_prepared(s: &mut crate::Session, mut data: CatalogImport, co | |
| Err(e) => warnings.push(format!("image {} XMP: {e}", src.source_id)), | ||
| } | ||
| } | ||
| // Lightroom's own caption, over the cached packet's (which can lack it or be older) | ||
| if !src.caption.is_empty() { | ||
| p.meta.caption = src.caption.clone(); | ||
| } | ||
| p.rating = number(&src.image, "rating").clamp(0, 5) as u8; | ||
| p.flag = match number(&src.image, "pick") { | ||
| 1 => Flag::Pick, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omit empty captions to preserve archive deduplication.
If a catalog has no captions, an archive written before this change has no
captionfields. The new archive has empty fields, sosame_boundedtreats the unchanged catalog as different. If eight archives already exist, storing it can retire an unrelated recovery copy.Skip serialization for empty captions. Older archives already deserialize missing captions as empty strings. Adjust the struct field count for the conditional field as well.