Refactor imag-contact for new libimagentryref API

This commit is contained in:
Matthias Beyer 2018-02-14 12:38:00 +01:00
parent 672873c2f1
commit 9ced9008b5
3 changed files with 6 additions and 9 deletions

View file

@ -28,7 +28,7 @@ toml-query = "0.6"
handlebars = "0.29" handlebars = "0.29"
vobject = "0.4" vobject = "0.4"
walkdir = "1" walkdir = "1"
uuid = { version = "0.5", features = ["v4"] } uuid = { version = "0.6", features = ["v4"] }
libimagrt = { version = "0.7.0", path = "../../../lib/core/libimagrt" } libimagrt = { version = "0.7.0", path = "../../../lib/core/libimagrt" }
libimagstore = { version = "0.7.0", path = "../../../lib/core/libimagstore" } libimagstore = { version = "0.7.0", path = "../../../lib/core/libimagstore" }

View file

@ -31,13 +31,13 @@ use toml::Value;
use uuid::Uuid; use uuid::Uuid;
use libimagcontact::error::ContactError as CE; use libimagcontact::error::ContactError as CE;
use libimagcontact::store::UniqueContactPathGenerator;
use libimagrt::runtime::Runtime; use libimagrt::runtime::Runtime;
use libimagerror::str::ErrFromStr; use libimagerror::str::ErrFromStr;
use libimagerror::trace::MapErrTrace; use libimagerror::trace::MapErrTrace;
use libimagerror::trace::trace_error; use libimagerror::trace::trace_error;
use libimagutil::warn_result::WarnResult; use libimagutil::warn_result::WarnResult;
use libimagentryref::refstore::RefStore; use libimagentryref::refstore::RefStore;
use libimagentryref::flags::RefFlags;
const TEMPLATE : &'static str = include_str!("../static/new-contact-template.toml"); const TEMPLATE : &'static str = include_str!("../static/new-contact-template.toml");
@ -144,11 +144,7 @@ pub fn create(rt: &Runtime) {
if let Some(location) = location { if let Some(location) = location {
if !scmd.is_present("dont-track") { if !scmd.is_present("dont-track") {
let flags = RefFlags::default() RefStore::create_ref::<UniqueContactPathGenerator, _>(rt.store(), location)
.with_content_hashing(true)
.with_permission_tracking(false);
RefStore::create(rt.store(), location, flags)
.map_err_trace_exit_unwrap(1); .map_err_trace_exit_unwrap(1);
info!("Created entry in store"); info!("Created entry in store");

View file

@ -67,6 +67,7 @@ use libimagerror::trace::MapErrTrace;
use libimagerror::io::ToExitCode; use libimagerror::io::ToExitCode;
use libimagerror::exit::ExitUnwrap; use libimagerror::exit::ExitUnwrap;
use libimagcontact::store::ContactStore; use libimagcontact::store::ContactStore;
use libimagcontact::store::UniqueContactPathGenerator;
use libimagcontact::error::ContactError as CE; use libimagcontact::error::ContactError as CE;
use libimagcontact::contact::Contact; use libimagcontact::contact::Contact;
use libimagstore::iter::get::StoreIdGetIteratorExtension; use libimagstore::iter::get::StoreIdGetIteratorExtension;
@ -130,7 +131,7 @@ fn list(rt: &Runtime) {
}) })
.enumerate() .enumerate()
.map(|(i, (fle, vcard))| { .map(|(i, (fle, vcard))| {
let hash = fle.get_path_hash().map_err_trace_exit_unwrap(1); let hash = String::from(fle.get_hash().map_err_trace_exit_unwrap(1));
let vcard = vcard.unwrap_or_else(|e| { let vcard = vcard.unwrap_or_else(|e| {
error!("Element is not a VCARD object: {:?}", e); error!("Element is not a VCARD object: {:?}", e);
exit(1) exit(1)
@ -190,7 +191,7 @@ fn show(rt: &Runtime) {
let hash = scmd.value_of("hash").map(String::from).unwrap(); // safed by clap let hash = scmd.value_of("hash").map(String::from).unwrap(); // safed by clap
let contact_data = rt.store() let contact_data = rt.store()
.get_by_hash(hash.clone()) .get_ref::<UniqueContactPathGenerator, _>(hash.clone())
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)
.ok_or(CE::from(format!("No entry for hash {}", hash))) .ok_or(CE::from(format!("No entry for hash {}", hash)))
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)