Merge pull request #450 from matthiasbeyer/imag-tag/get
Rewrite UI to use Store::get() which does not implicitely create entries
This commit is contained in:
commit
93f78e694a
1 changed files with 25 additions and 16 deletions
|
@ -62,10 +62,8 @@ fn alter(rt: &Runtime, id: &str, add: Option<Vec<Tag>>, rem: Option<Vec<Tag>>) {
|
||||||
};
|
};
|
||||||
debug!("path = {:?}", path);
|
debug!("path = {:?}", path);
|
||||||
|
|
||||||
rt.store()
|
match rt.store().get(path) {
|
||||||
// "id" must be present, enforced via clap spec
|
Ok(Some(mut e)) => {
|
||||||
.retrieve(path)
|
|
||||||
.map(|mut e| {
|
|
||||||
add.map(|tags| {
|
add.map(|tags| {
|
||||||
for tag in tags {
|
for tag in tags {
|
||||||
debug!("Adding tag '{:?}'", tag);
|
debug!("Adding tag '{:?}'", tag);
|
||||||
|
@ -83,12 +81,17 @@ fn alter(rt: &Runtime, id: &str, add: Option<Vec<Tag>>, rem: Option<Vec<Tag>>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}); // it is okay to ignore a None here
|
}); // it is okay to ignore a None here
|
||||||
})
|
},
|
||||||
.map_err(|e| {
|
|
||||||
|
Ok(None) => {
|
||||||
|
info!("No entry found.");
|
||||||
|
},
|
||||||
|
|
||||||
|
Err(e) => {
|
||||||
info!("No entry.");
|
info!("No entry.");
|
||||||
trace_error(&e);
|
trace_error(&e);
|
||||||
})
|
},
|
||||||
.ok();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list(id: &str, rt: &Runtime) {
|
fn list(id: &str, rt: &Runtime) {
|
||||||
|
@ -103,14 +106,20 @@ fn list(id: &str, rt: &Runtime) {
|
||||||
};
|
};
|
||||||
debug!("path = {:?}", path);
|
debug!("path = {:?}", path);
|
||||||
|
|
||||||
let entry = rt.store().retrieve(path.clone());
|
let entry = match rt.store().get(path.clone()) {
|
||||||
if entry.is_err() {
|
Ok(Some(e)) => e,
|
||||||
debug!("Could not retrieve '{:?}' => {:?}", id, path);
|
Ok(None) => {
|
||||||
warn!("Could not retrieve entry '{}'", id);
|
info!("No entry found.");
|
||||||
trace_error(&entry.unwrap_err());
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
},
|
||||||
let entry = entry.unwrap();
|
|
||||||
|
Err(e) => {
|
||||||
|
debug!("Could not get '{:?}' => {:?}", id, path);
|
||||||
|
warn!("Could not get entry '{}'", id);
|
||||||
|
trace_error(&e);
|
||||||
|
exit(1);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
let scmd = rt.cli().subcommand_matches("list").unwrap(); // safe, we checked in main()
|
let scmd = rt.cli().subcommand_matches("list").unwrap(); // safe, we checked in main()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue