Make tags unique before writing
This commit is contained in:
parent
9f8a648600
commit
2e2c6e19fa
3 changed files with 6 additions and 2 deletions
|
@ -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"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
extern crate clap;
|
||||
extern crate itertools;
|
||||
#[macro_use] extern crate log;
|
||||
extern crate regex;
|
||||
extern crate toml;
|
||||
|
|
|
@ -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(|_| ())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue