From 3440c8f6f36e90bbfdb2c8ef7b2da4b8a79203d5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 3 May 2017 18:44:20 +0200 Subject: [PATCH] Adapt DenyDeletionOfLinkedEntriesHook to toml 0.4 --- libimagstorestdhook/src/denylinkeddelete.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libimagstorestdhook/src/denylinkeddelete.rs b/libimagstorestdhook/src/denylinkeddelete.rs index 98f3a01a..6186535a 100644 --- a/libimagstorestdhook/src/denylinkeddelete.rs +++ b/libimagstorestdhook/src/denylinkeddelete.rs @@ -26,8 +26,9 @@ use libimagstore::hook::accessor::HookDataAccessorProvider; use libimagstore::hook::accessor::NonMutableHookDataAccessor; use libimagstore::hook::result::HookResult; use libimagstore::store::FileLockEntry; +use libimagstore::toml_ext::TomlValueExt; use libimagentrylink::internal::InternalLinker; - +use libimagerror::trace::trace_error; mod error { generate_error_imports!(); @@ -60,17 +61,22 @@ impl Hook for DenyDeletionOfLinkedEntriesHook { } fn set_config(&mut self, v: &Value) { - self.abort = match v.lookup("aborting") { - Some(&Value::Boolean(b)) => b, - Some(_) => { + self.abort = match v.read("aborting") { + Ok(Some(Value::Boolean(b))) => b, + Ok(Some(_)) => { warn!("Configuration error, 'aborting' must be a Boolean (true|false)."); warn!("Assuming 'true' now."); true }, - None => { + Ok(None) => { warn!("No key 'aborting' - Assuming 'true'"); true }, + Err(e) => { + error!("Error parsing TOML:"); + trace_error(&e); + false + }, }; }