Adapt DenyDeletionOfLinkedEntriesHook to toml 0.4

This commit is contained in:
Matthias Beyer 2017-05-03 18:44:20 +02:00
parent 2bad2ef501
commit 3440c8f6f3

View file

@ -26,8 +26,9 @@ use libimagstore::hook::accessor::HookDataAccessorProvider;
use libimagstore::hook::accessor::NonMutableHookDataAccessor; use libimagstore::hook::accessor::NonMutableHookDataAccessor;
use libimagstore::hook::result::HookResult; use libimagstore::hook::result::HookResult;
use libimagstore::store::FileLockEntry; use libimagstore::store::FileLockEntry;
use libimagstore::toml_ext::TomlValueExt;
use libimagentrylink::internal::InternalLinker; use libimagentrylink::internal::InternalLinker;
use libimagerror::trace::trace_error;
mod error { mod error {
generate_error_imports!(); generate_error_imports!();
@ -60,17 +61,22 @@ impl Hook for DenyDeletionOfLinkedEntriesHook {
} }
fn set_config(&mut self, v: &Value) { fn set_config(&mut self, v: &Value) {
self.abort = match v.lookup("aborting") { self.abort = match v.read("aborting") {
Some(&Value::Boolean(b)) => b, Ok(Some(Value::Boolean(b))) => b,
Some(_) => { Ok(Some(_)) => {
warn!("Configuration error, 'aborting' must be a Boolean (true|false)."); warn!("Configuration error, 'aborting' must be a Boolean (true|false).");
warn!("Assuming 'true' now."); warn!("Assuming 'true' now.");
true true
}, },
None => { Ok(None) => {
warn!("No key 'aborting' - Assuming 'true'"); warn!("No key 'aborting' - Assuming 'true'");
true true
}, },
Err(e) => {
error!("Error parsing TOML:");
trace_error(&e);
false
},
}; };
} }