Refactor imag-contact for new libimagentryref API
This commit is contained in:
parent
672873c2f1
commit
9ced9008b5
3 changed files with 6 additions and 9 deletions
|
@ -28,7 +28,7 @@ toml-query = "0.6"
|
|||
handlebars = "0.29"
|
||||
vobject = "0.4"
|
||||
walkdir = "1"
|
||||
uuid = { version = "0.5", features = ["v4"] }
|
||||
uuid = { version = "0.6", features = ["v4"] }
|
||||
|
||||
libimagrt = { version = "0.7.0", path = "../../../lib/core/libimagrt" }
|
||||
libimagstore = { version = "0.7.0", path = "../../../lib/core/libimagstore" }
|
||||
|
|
|
@ -31,13 +31,13 @@ use toml::Value;
|
|||
use uuid::Uuid;
|
||||
|
||||
use libimagcontact::error::ContactError as CE;
|
||||
use libimagcontact::store::UniqueContactPathGenerator;
|
||||
use libimagrt::runtime::Runtime;
|
||||
use libimagerror::str::ErrFromStr;
|
||||
use libimagerror::trace::MapErrTrace;
|
||||
use libimagerror::trace::trace_error;
|
||||
use libimagutil::warn_result::WarnResult;
|
||||
use libimagentryref::refstore::RefStore;
|
||||
use libimagentryref::flags::RefFlags;
|
||||
|
||||
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 !scmd.is_present("dont-track") {
|
||||
let flags = RefFlags::default()
|
||||
.with_content_hashing(true)
|
||||
.with_permission_tracking(false);
|
||||
|
||||
RefStore::create(rt.store(), location, flags)
|
||||
RefStore::create_ref::<UniqueContactPathGenerator, _>(rt.store(), location)
|
||||
.map_err_trace_exit_unwrap(1);
|
||||
|
||||
info!("Created entry in store");
|
||||
|
|
|
@ -67,6 +67,7 @@ use libimagerror::trace::MapErrTrace;
|
|||
use libimagerror::io::ToExitCode;
|
||||
use libimagerror::exit::ExitUnwrap;
|
||||
use libimagcontact::store::ContactStore;
|
||||
use libimagcontact::store::UniqueContactPathGenerator;
|
||||
use libimagcontact::error::ContactError as CE;
|
||||
use libimagcontact::contact::Contact;
|
||||
use libimagstore::iter::get::StoreIdGetIteratorExtension;
|
||||
|
@ -130,7 +131,7 @@ fn list(rt: &Runtime) {
|
|||
})
|
||||
.enumerate()
|
||||
.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| {
|
||||
error!("Element is not a VCARD object: {:?}", e);
|
||||
exit(1)
|
||||
|
@ -190,7 +191,7 @@ fn show(rt: &Runtime) {
|
|||
let hash = scmd.value_of("hash").map(String::from).unwrap(); // safed by clap
|
||||
|
||||
let contact_data = rt.store()
|
||||
.get_by_hash(hash.clone())
|
||||
.get_ref::<UniqueContactPathGenerator, _>(hash.clone())
|
||||
.map_err_trace_exit_unwrap(1)
|
||||
.ok_or(CE::from(format!("No entry for hash {}", hash)))
|
||||
.map_err_trace_exit_unwrap(1)
|
||||
|
|
Loading…
Reference in a new issue