From 0c461e126bb0da997f96a871ad28f0d517329013 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Sep 2017 14:33:32 +0200 Subject: [PATCH] Fix impl of GPSEntry::remove_coordinates() --- lib/entry/libimagentrygps/src/entry.rs | 29 ++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/entry/libimagentrygps/src/entry.rs b/lib/entry/libimagentrygps/src/entry.rs index 13b73ef5..1e54157e 100644 --- a/lib/entry/libimagentrygps/src/entry.rs +++ b/lib/entry/libimagentrygps/src/entry.rs @@ -72,10 +72,31 @@ impl GPSEntry for Entry { } fn remove_coordinates(&mut self) -> Result>> { - self.get_header_mut() - .delete("gps.coordinates") - .chain_err(|| GPSEK::HeaderWriteError) - .map(|opt| opt.as_ref().map(Coordinates::from_value)) + let coordinates = self.get_coordinates(); + + let patterns = [ + "gps.coordinates.latitude.degree", + "gps.coordinates.latitude.minutes", + "gps.coordinates.latitude.seconds", + "gps.coordinates.longitude.degree", + "gps.coordinates.longitude.minutes", + "gps.coordinates.longitude.seconds", + "gps.coordinates.latitude", + "gps.coordinates.longitude", + "gps.coordinates", + "gps", + ]; + + let mut hdr = self.get_header_mut(); + for pattern in patterns.iter() { + let _ = try!(hdr.delete(pattern).chain_err(|| GPSEK::HeaderWriteError)); + } + + match coordinates { + Ok(None) => Ok(None), + Ok(Some(some)) => Ok(Some(Ok(some))), + Err(e) => Ok(Some(Err(e))), + } } }