summaryrefslogtreecommitdiffstats
path: root/imag-link
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-08-26 10:20:34 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-08-28 18:41:56 +0200
commit17dbb1da298f20b14abf30a13f3745e2f0a64a82 (patch)
tree59815c2c2d8f9cc59d1fac44cbf7cac9db744769 /imag-link
parent5462714fcc18cf607af889ad282b628d9e6ec3db (diff)
Fix imga-link::main::* for new StoreId interface
Diffstat (limited to 'imag-link')
-rw-r--r--imag-link/src/main.rs30
1 files changed, 22 insertions, 8 deletions
diff --git a/imag-link/src/main.rs b/imag-link/src/main.rs
index c1448678..a43fb087 100644
--- a/imag-link/src/main.rs
+++ b/imag-link/src/main.rs
@@ -74,10 +74,10 @@ fn handle_internal_linking(rt: &Runtime) {
for entry in cmd.value_of("list").unwrap().split(',') {
debug!("Listing for '{}'", entry);
match get_entry_by_name(rt, entry) {
- Ok(e) => {
+ Ok(Some(e)) => {
e.get_internal_links()
.map(|links| {
- for (i, link) in links.iter().map(|l| l.to_str()).filter_map(|x| x).enumerate() {
+ for (i, link) in links.iter().map(|l| l.to_str().ok()).filter_map(|x| x).enumerate() {
println!("{: <3}: {}", i, link);
}
})
@@ -85,6 +85,11 @@ fn handle_internal_linking(rt: &Runtime) {
.ok();
},
+ Ok(None) => {
+ warn!("Entry not found: {:?}", entry);
+ break;
+ }
+
Err(e) => {
trace_error(&e);
break;
@@ -148,7 +153,8 @@ fn get_from_entry<'a>(rt: &'a Runtime) -> Option<FileLockEntry<'a>> {
debug!("We couldn't get the entry from name: '{:?}'", from_name);
trace_error(&e); None
},
- Ok(e) => Some(e),
+ Ok(Some(e)) => Some(e),
+ Ok(None) => None,
}
})
@@ -166,17 +172,20 @@ fn get_to_entries<'a>(rt: &'a Runtime) -> Option<Vec<FileLockEntry<'a>>> {
for entry in values.map(|v| get_entry_by_name(rt, v)) {
match entry {
Err(e) => trace_error(&e),
- Ok(e) => v.push(e),
+ Ok(Some(e)) => v.push(e),
+ Ok(None) => warn!("Entry not found: {:?}", v),
}
}
v
})
}
-fn get_entry_by_name<'a>(rt: &'a Runtime, name: &str) -> Result<FileLockEntry<'a>, StoreError> {
- use libimagstore::storeid::build_entry_path;
- build_entry_path(rt.store(), name)
- .and_then(|path| rt.store().retrieve(path))
+fn get_entry_by_name<'a>(rt: &'a Runtime, name: &str) -> Result<Option<FileLockEntry<'a>>, StoreError> {
+ use std::path::PathBuf;
+ use libimagstore::storeid::StoreId;
+
+ StoreId::new(Some(rt.store().path().clone()), PathBuf::from(name))
+ .and_then(|id| rt.store().get(id))
}
fn handle_external_linking(rt: &Runtime) {
@@ -186,6 +195,11 @@ fn handle_external_linking(rt: &Runtime) {
if entry.is_err() {
trace_error_exit(&entry.unwrap_err(), 1);
}
+ let entry = entry.unwrap();
+ if entry.is_none() {
+ warn!("Entry nt found: {:?}", entry_name);
+ return;
+ }
let mut entry = entry.unwrap();
if scmd.is_present("add") {