diff --git a/libimagtag/Cargo.toml b/libimagtag/Cargo.toml index 0fd71402..77ccf5af 100644 --- a/libimagtag/Cargo.toml +++ b/libimagtag/Cargo.toml @@ -8,6 +8,7 @@ clap = "2.1.1" log = "0.3.5" regex = "0.1.47" toml = "0.1.25" +itertools = "0.4.7" [dependencies.libimagstore] path = "../libimagstore" diff --git a/libimagtag/src/lib.rs b/libimagtag/src/lib.rs index edded91b..c5fbc7a3 100644 --- a/libimagtag/src/lib.rs +++ b/libimagtag/src/lib.rs @@ -1,4 +1,5 @@ extern crate clap; +extern crate itertools; #[macro_use] extern crate log; extern crate regex; extern crate toml; diff --git a/libimagtag/src/tagable.rs b/libimagtag/src/tagable.rs index 70eaec02..bd478a97 100644 --- a/libimagtag/src/tagable.rs +++ b/libimagtag/src/tagable.rs @@ -1,6 +1,8 @@ use std::ops::Deref; use std::ops::DerefMut; +use itertools::Itertools; + use libimagstore::store::{Entry, EntryHeader, FileLockEntry}; use error::{TagError, TagErrorKind}; @@ -66,7 +68,7 @@ impl Tagable for EntryHeader { return Err(TagError::new(TagErrorKind::NotATag, None)); } - let a = ts.iter().map(|t| Value::String(t.clone())).collect(); + let a = ts.iter().unique().map(|t| Value::String(t.clone())).collect(); self.set("imag.tags", Value::Array(a)) .map(|_| ()) .map_err(|e| TagError::new(TagErrorKind::HeaderWriteError, Some(Box::new(e)))) @@ -81,7 +83,7 @@ impl Tagable for EntryHeader { self.get_tags() .map(|mut tags| { tags.push(t); - self.set_tags(tags) + self.set_tags(tags.into_iter().unique().collect()) }) .map(|_| ()) }