Fix imag-store::{create, delete, get, retrieve, update}::* for new StoreId interface

This commit is contained in:
Matthias Beyer 2016-08-26 12:52:57 +02:00
parent fedb75ec98
commit 372d46d2aa
5 changed files with 21 additions and 15 deletions

View file

@ -13,8 +13,6 @@ use clap::ArgMatches;
use libimagrt::runtime::Runtime;
use libimagstore::store::Entry;
use libimagstore::store::EntryHeader;
use libimagstore::storeid::build_entry_path;
use libimagerror::trace::trace_error_exit;
use error::StoreError;
use error::StoreErrorKind;
@ -36,10 +34,7 @@ pub fn create(rt: &Runtime) {
exit(1);
}
let path = match build_entry_path(rt.store(), path.unwrap()) {
Err(e) => trace_error_exit(&e, 1),
Ok(p) => p,
};
let path = PathBuf::from(path.unwrap());
debug!("path = {:?}", path);
if scmd.subcommand_matches("entry").is_some() {
@ -111,7 +106,7 @@ fn create_with_content_and_header(rt: &Runtime,
content: String,
header: EntryHeader) -> Result<()>
{
debug!("Creating entry with content");
debug!("Creating entry with content at {:?}", path);
rt.store()
.create(PathBuf::from(path))
.map(|mut element| {

View file

@ -1,6 +1,8 @@
use libimagstore::storeid::build_entry_path;
use std::path::PathBuf;
use libimagrt::runtime::Runtime;
use libimagerror::trace::trace_error_exit;
use libimagstore::storeid::StoreId;
pub fn delete(rt: &Runtime) {
use std::process::exit;
@ -10,7 +12,8 @@ pub fn delete(rt: &Runtime) {
.map(|sub| {
sub.value_of("id")
.map(|id| {
let path = try!(build_entry_path(rt.store(), id)
let path = PathBuf::from(id);
let path = try!(StoreId::new(Some(rt.store().path().clone()), path)
.map_err(|e| trace_error_exit(&e, 1)));
debug!("Deleting file at {:?}", id);

View file

@ -1,6 +1,8 @@
use libimagstore::storeid::build_entry_path;
use std::path::PathBuf;
use libimagrt::runtime::Runtime;
use libimagerror::trace::{trace_error, trace_error_exit};
use libimagstore::storeid::StoreId;
use retrieve::print_entry;
@ -10,7 +12,8 @@ pub fn get(rt: &Runtime) {
.map(|scmd| {
scmd.value_of("id")
.map(|id| {
let path = match build_entry_path(rt.store(), id) {
let path = PathBuf::from(id);
let path = match StoreId::new(Some(rt.store().path().clone()), path) {
Err(e) => trace_error_exit(&e, 1),
Ok(p) => p,
};

View file

@ -1,8 +1,10 @@
use std::path::PathBuf;
use clap::ArgMatches;
use toml::Value;
use libimagstore::store::FileLockEntry;
use libimagstore::storeid::build_entry_path;
use libimagstore::storeid::StoreId;
use libimagrt::runtime::Runtime;
use libimagerror::trace::{trace_error, trace_error_exit};
@ -12,7 +14,8 @@ pub fn retrieve(rt: &Runtime) {
.map(|scmd| {
scmd.value_of("id")
.map(|id| {
let path = try!(build_entry_path(rt.store(), id)
let path = PathBuf::from(id);
let path = try!(StoreId::new(Some(rt.store().path().clone()), path)
.map_err(|e| trace_error_exit(&e, 1)));
debug!("path = {:?}", path);

View file

@ -1,8 +1,9 @@
use std::ops::DerefMut;
use std::path::PathBuf;
use libimagrt::runtime::Runtime;
use libimagstore::storeid::build_entry_path;
use libimagerror::trace::trace_error_exit;
use libimagstore::storeid::StoreId;
use util::build_toml_header;
@ -12,7 +13,8 @@ pub fn update(rt: &Runtime) {
.map(|scmd| {
scmd.value_of("id")
.map(|id| {
let path = match build_entry_path(rt.store(), id) {
let path = PathBuf::from(id);
let path = match StoreId::new(Some(rt.store().path().clone()), path) {
Err(e) => trace_error_exit(&e, 1),
Ok(p) => p,
};