[niepce] Issue #2 - If merge fails, use the original metadata



commit fcf8d792dcf47bc23a7e727691cba879c25c4436
Author: Hubert Figuière <hub figuiere net>
Date:   Mon Nov 26 00:20:19 2018 -0500

    Issue #2 - If merge fails, use the original metadata
    
    https://gitlab.gnome.org/GNOME/niepce/issues/2

 src/fwk/utils/exempi.rs | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/src/fwk/utils/exempi.rs b/src/fwk/utils/exempi.rs
index 151cfe6..d5fc77b 100644
--- a/src/fwk/utils/exempi.rs
+++ b/src/fwk/utils/exempi.rs
@@ -167,19 +167,18 @@ impl XmpMeta {
             if meta.is_some() {
                 return meta;
             }
-            return sidecar_meta;
-
+            sidecar_meta
         } else {
             let mut final_meta = sidecar_meta.unwrap();
             if !meta.as_ref().unwrap().merge_missing_into_xmp(&mut final_meta) {
                 err_out!("xmp merge failed");
+                // XXX with the current heuristics, it is probably safe to just
+                // keep the source metadata.
+                meta
             } else {
-                return Some(final_meta);
+                Some(final_meta)
             }
         }
-        // XXX maybe we should be more permissible. Returning the
-        // built-in meta if merge failed might not be the best option.
-        None
     }
 
     ///
@@ -201,7 +200,7 @@ impl XmpMeta {
             return false;
         }
 
-        // in properties in source not in destination gets copied over.
+        // Properties in source but not in destination gets copied over.
         let mut iter = exempi::XmpIterator::new(&self.xmp, "", "", exempi::ITER_PROPERTIES);
         {
             use exempi::XmpString;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]