~matthiasbeyer/imag

8ffb06cef3ac7a066a74121abd406f731073b8a0 — Matthias Beyer 1 year, 4 months ago 1c5a81d
Replace map_dbg_err() calls with context() calls

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
M lib/core/libimagstore/src/store.rs => lib/core/libimagstore/src/store.rs +1 -5
@@ 47,9 47,6 @@ use crate::file_abstraction::FileAbstractionInstance;
use crate::file_abstraction::fs::FSFileAbstraction;
use crate::file_abstraction::inmemory::InMemoryFileAbstraction;

use libimagutil::debug_result::*;


#[derive(Debug, PartialEq)]
enum StoreEntryStatus {
    Present,


@@ 199,8 196,7 @@ impl Store {

            backend
                .create_dir_all(&location)
                .context(format_err!("StorePathCreate: {}", location.display()))
                .map_dbg_err_str("Failed")?;
                .context(format_err!("StorePathCreate: {}", location.display()))?;
        } else if location.is_file() {
            debug!("Store path exists as file");
            return Err(format_err!("StorePathExists: {}", location.display()));

M lib/entry/libimagentryurl/src/iter.rs => lib/entry/libimagentryurl/src/iter.rs +5 -2
@@ 35,6 35,8 @@ use libimagstore::store::Store;
use libimagutil::debug_result::DebugResult;

use failure::Fallible as Result;
use failure::ResultExt;
use failure::Error;
use url::Url;

/// Helper for building `OnlyUrlIter` and `NoUrlIter`


@@ 170,14 172,15 @@ impl<'a> Iterator for UrlIter<'a> {
                    debug!("Retrieving entry for id: '{:?}'", id);
                    self.1
                        .retrieve(id.clone())
                        .map_dbg_err(|_| format!("Retrieving entry for id: '{:?}' failed", id))
                        .with_context(|e| format!("Retrieving entry for id: '{:?}' failed: {}", id, e))
                        .map_err(From::from)
                        .and_then(|f| {
                            debug!("Store::retrieve({:?}) succeeded", id);
                            debug!("getting uri link from file now");
                            f.get_url()
                                .map_dbg_str("Error happened while getting link URI from FLE")
                                .map_dbg_err(|e| format!("URL -> Err = {:?}", e))
                                .with_context(|e| format!("URL -> Err = {:?}", e))
                                .map_err(Error::from)
                        })
                });


M lib/entry/libimagentryurl/src/linker.rs => lib/entry/libimagentryurl/src/linker.rs +3 -5
@@ 20,10 20,10 @@
use libimagstore::storeid::StoreId;
use libimagstore::store::Store;
use libimagstore::store::Entry;
use libimagutil::debug_result::DebugResult;
use libimagentrylink::linkable::Linkable;

use failure::Fallible as Result;
use failure::ResultExt;
use url::Url;
use sha1::{Sha1, Digest};
use hex;


@@ 93,7 93,7 @@ impl UrlLinker for Entry {
        links.into_iter().map(|link| {
            let hash = hex::encode(Sha1::digest(&link.as_str().as_bytes()));
            let file_id = crate::module_path::new_id(hash.clone())
                .map_dbg_err(|_| format!("Failed to build StoreId for this hash '{:?}'", hash))?;
                .with_context(|e| format!("Failed to build StoreId for this hash '{:?}': {}", hash, e))?;

            debug!("Link    = '{:?}'", link);
            debug!("Hash    = '{:?}'", hash);


@@ 105,9 105,7 @@ impl UrlLinker for Entry {
            // exist
            let mut file = store
                .retrieve(file_id.clone())
                .map_dbg_err(|_| {
                    format!("Failed to create or retrieve an file for this link '{:?}'", link)
                })?;
                .with_context(|e| format!("Failed to create or retrieve an file for this link '{:?}': {}", link, e))?;

            debug!("Generating header content!");
            file.set_url(link)?;