~matthiasbeyer/imag

a4bcefe660468f740bf9a455c97b8be8e6cda0cc — Matthias Beyer 2 years ago de522ec + cb4d536
Merge branch 'rewrite-module-entry-path'

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
M lib/core/libimagstore/src/storeid.rs => lib/core/libimagstore/src/storeid.rs +16 -29
@@ 212,7 212,7 @@ impl<'a> Display for StoreIdWithBase<'a> {
#[macro_export]
macro_rules! module_entry_path_mod {
    ($name:expr) => (
        #[deny(missing_docs,
        #[allow(missing_docs,
                missing_copy_implementations,
                trivial_casts, trivial_numeric_casts,
                unstable_features,


@@ 223,34 223,23 @@ macro_rules! module_entry_path_mod {
            use std::convert::AsRef;
            use std::path::Path;
            use std::path::PathBuf;

            use $crate::storeid::StoreId;
            use failure::Fallible as Result;

            /// A Struct giving you the ability to choose store entries assigned
            /// to it.
            ///
            /// It is created through a call to `new`.
            pub struct ModuleEntryPath(PathBuf);

            impl ModuleEntryPath {
                /// Path has to be a valid UTF-8 string or this will panic!
                pub fn new<P: AsRef<Path>>(pa: P) -> ModuleEntryPath {
                    let mut path = PathBuf::new();
                    path.push(format!("{}", $name));
                    path.push(pa.as_ref().clone());
                    let name = pa.as_ref().file_name().unwrap()
                        .to_str().unwrap();
                    path.set_file_name(name);
                    ModuleEntryPath(path)
                }
            }
            pub fn new_id<P: AsRef<Path>>(p: P) -> Result<StoreId> {

                let path_str = p
                    .as_ref()
                    .to_str()
                    .ok_or_else(|| {
                        format_err!("File path is not valid UTF-8: {}", p.as_ref().display())
                    })?;

            impl $crate::storeid::IntoStoreId for ModuleEntryPath {
                fn into_storeid(self) -> Result<$crate::storeid::StoreId> {
                    StoreId::new(self.0)
                }
                let id = format!("{}/{}", $name, path_str);

                StoreId::new(PathBuf::from(id))
            }

        }
    )
}


@@ 351,20 340,18 @@ impl<'a> StoreIdIteratorWithStore<'a> {

#[cfg(test)]
mod test {
    use storeid::IntoStoreId;

    module_entry_path_mod!("test");

    #[test]
    fn test_correct_path() {
        let p = module_path::ModuleEntryPath::new("test");
        let p = ::storeid::test::module_path::new_id("test");

        assert_eq!(p.into_storeid().unwrap().to_str().unwrap(), "test/test");
        assert_eq!(p.unwrap().to_str().unwrap(), "test/test");
    }

    #[test]
    fn storeid_in_collection() {
        let p = module_path::ModuleEntryPath::new("1/2/3/4/5/6/7/8/9/0").into_storeid().unwrap();
        let p = ::storeid::test::module_path::new_id("1/2/3/4/5/6/7/8/9/0").unwrap();

        assert!(p.is_in_collection(&["test", "1"]));
        assert!(p.is_in_collection(&["test", "1", "2"]));

M lib/domain/libimagbookmark/src/collection.rs => lib/domain/libimagbookmark/src/collection.rs +3 -8
@@ 28,12 28,10 @@ use regex::Regex;

use failure::Fallible as Result;
use failure::Error;
use module_path::ModuleEntryPath;

use libimagstore::store::Store;
use libimagstore::store::Entry;
use libimagstore::store::FileLockEntry;
use libimagstore::storeid::IntoStoreId;
use libimagstore::storeid::StoreId;
use libimagentrylink::external::ExternalLinker;
use libimagentrylink::external::iter::UrlIter;


@@ 53,22 51,19 @@ pub trait BookmarkCollectionStore<'a> {
impl<'a> BookmarkCollectionStore<'a> for Store {

    fn new(&'a self, name: &str) -> Result<FileLockEntry<'a>> {
        ModuleEntryPath::new(name)
            .into_storeid()
        ::module_path::new_id(name)
            .and_then(|id| self.create(id).map_err(Error::from))
            .map_err(Error::from)
    }

    fn get(&'a self, name: &str) -> Result<Option<FileLockEntry<'a>>> {
        ModuleEntryPath::new(name)
            .into_storeid()
        ::module_path::new_id(name)
            .and_then(|id| self.get(id).map_err(Error::from))
            .map_err(Error::from)
    }

    fn delete(&'a self, name: &str) -> Result<()> {
        ModuleEntryPath::new(name)
            .into_storeid()
        ::module_path::new_id(name)
            .and_then(|id| self.delete(id).map_err(Error::from))
            .map_err(Error::from)
    }

M lib/domain/libimagbookmark/src/lib.rs => lib/domain/libimagbookmark/src/lib.rs +1 -1
@@ 39,7 39,7 @@

extern crate url;
extern crate regex;
extern crate failure;
#[macro_use] extern crate failure;

#[macro_use] extern crate libimagstore;
extern crate libimagerror;

M lib/domain/libimagcontact/src/store.rs => lib/domain/libimagcontact/src/store.rs +1 -3
@@ 27,7 27,6 @@ use vobject::vcard::Vcard;
use failure::Error;
use failure::Fallible as Result;

use libimagstore::storeid::IntoStoreId;
use libimagstore::storeid::StoreId;
use libimagstore::iter::Entries;
use libimagstore::store::Store;


@@ 36,7 35,6 @@ use libimagentryutil::isa::Is;

use contact::IsContact;
use deser::DeserVcard;
use module_path::ModuleEntryPath;
use util;

pub trait ContactStore<'a> {


@@ 98,7 96,7 @@ fn prepare_fetching_from_store(buf: &str) -> Result<(StoreId, Value)> {
        toml_from_str::<Value>(&serialized)?
    };

    let sid = ModuleEntryPath::new(uid.raw()).into_storeid()?;
    let sid = ::module_path::new_id(uid.raw())?;

    Ok((sid, value))
}

M lib/domain/libimagdiary/src/diaryid.rs => lib/domain/libimagdiary/src/diaryid.rs +2 -3
@@ 34,8 34,6 @@ use failure::err_msg;
use libimagstore::storeid::StoreId;
use libimagstore::storeid::IntoStoreId;

use module_path::ModuleEntryPath;

#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq)]
pub struct DiaryId {
    name: String,


@@ 150,8 148,9 @@ impl DiaryId {
impl IntoStoreId for DiaryId {

    fn into_storeid(self) -> Result<StoreId> {
        use std::path::PathBuf;
        let s : String = self.into();
        ModuleEntryPath::new(s).into_storeid()
        ::module_path::new_id(PathBuf::from(s))
    }

}

M lib/domain/libimagdiary/src/lib.rs => lib/domain/libimagdiary/src/lib.rs +1 -1
@@ 42,7 42,7 @@ extern crate chrono;
extern crate toml;
extern crate toml_query;
extern crate itertools;
extern crate failure;
#[macro_use] extern crate failure;
extern crate filters;

#[macro_use] extern crate libimagstore;

M lib/domain/libimaghabit/src/habit.rs => lib/domain/libimaghabit/src/habit.rs +2 -9
@@ 37,7 37,6 @@ use libimagstore::store::Store;
use libimagstore::store::FileLockEntry;
use libimagstore::store::Entry;
use libimagstore::storeid::StoreId;
use libimagstore::storeid::IntoStoreId;
use libimagstore::storeid::StoreIdIterator;
use libimagentryutil::isa::Is;
use libimagentryutil::isa::IsKindHeaderPathProvider;


@@ 258,11 257,7 @@ impl HabitTemplate for Entry {
}

fn instance_id_for_name_and_datestr(habit_name: &String, habit_date: &String) -> Result<StoreId> {
    use module_path::ModuleEntryPath;

    ModuleEntryPath::new(format!("instance/{}-{}", habit_name, habit_date))
        .into_storeid()
        .map_err(Error::from)
    ::module_path::new_id(format!("instance/{}-{}", habit_name, habit_date)).map_err(Error::from)
}

pub mod builder {


@@ 272,7 267,6 @@ pub mod builder {

    use libimagstore::store::Store;
    use libimagstore::storeid::StoreId;
    use libimagstore::storeid::IntoStoreId;
    use libimagstore::store::FileLockEntry;
    use libimagentryutil::isa::Is;
    use libimagutil::debug_result::DebugResult;


@@ 393,8 387,7 @@ pub mod builder {

    /// Buld a StoreId for a Habit from a date object and a name of a habit
    fn build_habit_template_sid(name: &String) -> Result<StoreId> {
        use module_path::ModuleEntryPath;
        ModuleEntryPath::new(format!("template/{}", name)).into_storeid().map_err(From::from)
        ::module_path::new_id(format!("template/{}", name)).map_err(From::from)
    }

}

M lib/domain/libimagmail/src/store.rs => lib/domain/libimagmail/src/store.rs +3 -5
@@ 27,7 27,6 @@ use toml_query::insert::TomlValueInsertExt;

use libimagstore::store::FileLockEntry;
use libimagstore::store::Store;
use libimagstore::storeid::IntoStoreId;
use libimagstore::storeid::StoreId;
use libimagstore::iter::Entries;
use libimagentryref::hasher::default::DefaultHasher;


@@ 36,7 35,6 @@ use libimagentryref::reference::RefFassade;
use libimagentryref::reference::Ref;
use libimagentryref::reference::MutRef;

use module_path::ModuleEntryPath;
use mid::MessageId;
use mail::Mail;
use hasher::MailHasher;


@@ 69,7 67,7 @@ impl<'a> MailStore<'a> for Store {
              CollName: AsRef<str> + Debug
    {
        let message_id = get_message_id_for_mailfile(p.as_ref())?;
        let new_sid    = ModuleEntryPath::new(message_id.clone()).into_storeid()?;
        let new_sid    = ::module_path::new_id(message_id.clone())?;

        let mut entry = self.create(new_sid)?;
        let _         = entry


@@ 90,7 88,7 @@ impl<'a> MailStore<'a> for Store {
        where P: AsRef<Path> + Debug
    {
        let message_id = get_message_id_for_mailfile(p.as_ref())?;
        let new_sid    = ModuleEntryPath::new(message_id.clone()).into_storeid()?;
        let new_sid    = ::module_path::new_id(message_id.clone())?;

        match self.get(new_sid)? {
            Some(mut entry) => {


@@ 117,7 115,7 @@ impl<'a> MailStore<'a> for Store {
              CollName: AsRef<str> + Debug
    {
        let message_id = get_message_id_for_mailfile(&p)?;
        let new_sid    = ModuleEntryPath::new(message_id.clone()).into_storeid()?;
        let new_sid    = ::module_path::new_id(message_id.clone())?;
        let mut entry  = self.retrieve(new_sid)?;

        let _ = entry

M lib/domain/libimagnotes/src/lib.rs => lib/domain/libimagnotes/src/lib.rs +1 -1
@@ 40,7 40,7 @@
#[macro_use] extern crate log;
extern crate toml;
extern crate toml_query;
extern crate failure;
#[macro_use] extern crate failure;

extern crate libimagrt;
#[macro_use] extern crate libimagstore;

M lib/domain/libimagnotes/src/notestore.rs => lib/domain/libimagnotes/src/notestore.rs +4 -8
@@ 19,14 19,12 @@

use toml::Value;

use libimagstore::storeid::IntoStoreId;
use libimagstore::store::FileLockEntry;
use libimagstore::store::Store;

use toml_query::insert::TomlValueInsertExt;
use failure::Fallible as Result;

use module_path::ModuleEntryPath;
use iter::*;

pub trait NoteStore<'a> {


@@ 45,9 43,7 @@ impl<'a> NoteStore<'a> for Store {

        debug!("Creating new Note: '{}'", name);
        let fle = {
            let mut lockentry = ModuleEntryPath::new(name.clone())
                .into_storeid()
                .and_then(|id| self.create(id))?;
            let mut lockentry = ::module_path::new_id(name.clone()).and_then(|id| self.create(id))?;

            {
                let entry  = lockentry.deref_mut();


@@ 62,15 58,15 @@ impl<'a> NoteStore<'a> for Store {
    }

    fn delete_note(&'a self, name: String) -> Result<()> {
        ModuleEntryPath::new(name).into_storeid().and_then(|id| self.delete(id))
        ::module_path::new_id(name).and_then(|id| self.delete(id))
    }

    fn retrieve_note(&'a self, name: String) -> Result<FileLockEntry<'a>> {
        ModuleEntryPath::new(name).into_storeid().and_then(|id| self.retrieve(id))
        ::module_path::new_id(name).and_then(|id| self.retrieve(id))
    }

    fn get_note(&'a self, name: String) -> Result<Option<FileLockEntry<'a>>> {
        ModuleEntryPath::new(name).into_storeid().and_then(|id| self.get(id))
        ::module_path::new_id(name).and_then(|id| self.get(id))
    }

    fn all_notes(&'a self) -> Result<NoteIterator> {

M lib/domain/libimagtimetrack/src/iter/storeid.rs => lib/domain/libimagtimetrack/src/iter/storeid.rs +1 -5
@@ 49,16 49,12 @@ impl Iterator for TagStoreIdIter {
    type Item = Result<(StoreId, NDT)>;

    fn next(&mut self) -> Option<Self::Item> {
        use module_path::ModuleEntryPath;
        use libimagstore::storeid::IntoStoreId;

        self.inner
            .next()
            .map(|res| res.and_then(|tag| {
                let dt     = self.datetime.format(DATE_TIME_FORMAT).to_string();
                let id_str = format!("{}-{}", dt, tag.as_str());
                ModuleEntryPath::new(id_str)
                    .into_storeid()
                ::module_path::new_id(id_str)
                    .map_err(Error::from)
                    .map(|id| (id, self.datetime.clone()))
            }))

M lib/domain/libimagtimetrack/src/lib.rs => lib/domain/libimagtimetrack/src/lib.rs +1 -1
@@ 45,7 45,7 @@ extern crate toml_query;
extern crate lazy_static;
#[macro_use]
extern crate is_match;
extern crate failure;
#[macro_use] extern crate failure;

#[macro_use]
extern crate libimagstore;

M lib/domain/libimagtodo/src/lib.rs => lib/domain/libimagtodo/src/lib.rs +1 -1
@@ 42,7 42,7 @@ extern crate toml;
extern crate toml_query;
#[macro_use] extern crate log;
extern crate serde_json;
extern crate failure;
#[macro_use] extern crate failure;

#[macro_use] extern crate libimagstore;
extern crate libimagerror;

M lib/domain/libimagtodo/src/taskstore.rs => lib/domain/libimagtodo/src/taskstore.rs +16 -25
@@ 32,9 32,7 @@ use failure::Error;
use failure::err_msg;

use libimagstore::store::{FileLockEntry, Store};
use libimagstore::storeid::IntoStoreId;
use libimagerror::errors::ErrorMsg as EM;
use module_path::ModuleEntryPath;

use iter::TaskIdIterator;



@@ 101,9 99,7 @@ impl<'a> TaskStore<'a> for Store {
    ///
    /// If there is no task with this UUID, this returns `Ok(None)`.
    fn get_task_from_uuid(&'a self, uuid: Uuid) -> Result<Option<FileLockEntry<'a>>> {
        ModuleEntryPath::new(format!("taskwarrior/{}", uuid))
            .into_storeid()
            .and_then(|store_id| self.get(store_id))
        ::module_path::new_id(format!("taskwarrior/{}", uuid)).and_then(|store_id| self.get(store_id))
    }

    /// Same as Task::get_from_import() but uses Store::retrieve() rather than Store::get(), to


@@ 154,9 150,7 @@ impl<'a> TaskStore<'a> for Store {
    }

    fn delete_task_by_uuid(&self, uuid: Uuid) -> Result<()> {
        ModuleEntryPath::new(format!("taskwarrior/{}", uuid))
            .into_storeid()
            .and_then(|id| self.delete(id))
        ::module_path::new_id(format!("taskwarrior/{}", uuid)).and_then(|id| self.delete(id))
    }

    fn all_tasks(&self) -> Result<TaskIdIterator> {


@@ 168,24 162,21 @@ impl<'a> TaskStore<'a> for Store {
        use toml_query::set::TomlValueSetExt;

        let uuid     = task.uuid();
        ModuleEntryPath::new(format!("taskwarrior/{}", uuid))
            .into_storeid()
            .and_then(|id| {
                self.retrieve(id)
                    .and_then(|mut fle| {
                        {
                            let hdr = fle.get_header_mut();
                            if hdr.read("todo")?.is_none() {
                                hdr.set("todo", Value::Table(BTreeMap::new()))?;
                            }

                            hdr.set("todo.uuid", Value::String(format!("{}",uuid)))?;
                        }

                        // If none of the errors above have returned the function, everything is fine
                        Ok(fle)
                    })
        ::module_path::new_id(format!("taskwarrior/{}", uuid)).and_then(|id| {
            self.retrieve(id).and_then(|mut fle| {
                {
                    let hdr = fle.get_header_mut();
                    if hdr.read("todo")?.is_none() {
                        hdr.set("todo", Value::Table(BTreeMap::new()))?;
                    }

                    hdr.set("todo.uuid", Value::String(format!("{}",uuid)))?;
                }

                // If none of the errors above have returned the function, everything is fine
                Ok(fle)
            })
        })

    }


M lib/domain/libimagwiki/src/store.rs => lib/domain/libimagwiki/src/store.rs +1 -2
@@ 20,7 20,6 @@
use libimagstore::store::FileLockEntry;
use libimagstore::store::Store;
use libimagstore::storeid::StoreId;
use libimagstore::storeid::IntoStoreId;

use failure::Fallible as Result;



@@ 83,6 82,6 @@ impl WikiStore for Store {
}

fn wiki_path(name: &str) -> Result<StoreId> {
    ::module_path::ModuleEntryPath::new(name).into_storeid()
    ::module_path::new_id(name)
}


M lib/domain/libimagwiki/src/wiki.rs => lib/domain/libimagwiki/src/wiki.rs +10 -11
@@ 21,7 21,6 @@ use std::path::PathBuf;

use libimagstore::store::Store;
use libimagstore::store::FileLockEntry;
use libimagstore::storeid::IntoStoreId;
use libimagstore::iter::Entries;
use libimagentrylink::internal::InternalLinker;



@@ 48,14 47,14 @@ impl<'a, 'b> Wiki<'a, 'b> {

    pub(crate) fn create_index_page(&self) -> Result<FileLockEntry<'a>> {
        let path = PathBuf::from(format!("{}/index", self.1));
        let sid  = ::module_path::ModuleEntryPath::new(path).into_storeid()?;
        let sid  = ::module_path::new_id(path)?;

        self.0.create(sid)
    }

    pub(crate) fn get_index_page(&self) -> Result<FileLockEntry<'a>> {
        let path = PathBuf::from(format!("{}/index", self.1));
        let sid  = ::module_path::ModuleEntryPath::new(path).into_storeid()?;
        let sid  = ::module_path::new_id(path)?;

        self.0
            .get(sid)


@@ 64,14 63,14 @@ impl<'a, 'b> Wiki<'a, 'b> {
    }

    pub fn get_entry<EN: AsRef<str>>(&self, entry_name: EN) -> Result<Option<FileLockEntry<'a>>> {
        let path  = PathBuf::from(format!("{}/{}", self.1, entry_name.as_ref()));
        let sid   = ::module_path::ModuleEntryPath::new(path).into_storeid()?;
        let path = PathBuf::from(format!("{}/{}", self.1, entry_name.as_ref()));
        let sid  = ::module_path::new_id(path)?;
        self.0.get(sid)
    }

    pub fn create_entry<EN: AsRef<str>>(&self, entry_name: EN) -> Result<FileLockEntry<'a>> {
        let path      = PathBuf::from(format!("{}/{}", self.1, entry_name.as_ref()));
        let sid       = ::module_path::ModuleEntryPath::new(path).into_storeid()?;
        let path = PathBuf::from(format!("{}/{}", self.1, entry_name.as_ref()));
        let sid  = ::module_path::new_id(path)?;
        let mut index = self
            .get_entry("index")?
            .ok_or_else(|| err_msg("Missing index page"))?;


@@ 81,8 80,8 @@ impl<'a, 'b> Wiki<'a, 'b> {
    }

    pub fn retrieve_entry<EN: AsRef<str>>(&self, entry_name: EN) -> Result<FileLockEntry<'a>> {
        let path      = PathBuf::from(format!("{}/{}", self.1, entry_name.as_ref()));
        let sid       = ::module_path::ModuleEntryPath::new(path).into_storeid()?;
        let path = PathBuf::from(format!("{}/{}", self.1, entry_name.as_ref()));
        let sid  = ::module_path::new_id(path)?;
        let mut index = self
            .get_entry("index")?
            .ok_or_else(|| err_msg("Missing index page"))?;


@@ 96,8 95,8 @@ impl<'a, 'b> Wiki<'a, 'b> {
    }

    pub fn delete_entry<EN: AsRef<str>>(&self, entry_name: EN) -> Result<()> {
        let path  = PathBuf::from(format!("{}/{}", self.1, entry_name.as_ref()));
        let sid   = ::module_path::ModuleEntryPath::new(path).into_storeid()?;
        let path = PathBuf::from(format!("{}/{}", self.1, entry_name.as_ref()));
        let sid  = ::module_path::new_id(path)?;
        self.0.delete(sid)
    }
}

M lib/entry/libimagentryannotation/src/annotateable.rs => lib/entry/libimagentryannotation/src/annotateable.rs +2 -5
@@ 23,7 23,6 @@ use uuid::Uuid;
use libimagstore::store::Entry;
use libimagstore::store::FileLockEntry;
use libimagstore::store::Store;
use libimagstore::storeid::IntoStoreId;
use libimagstore::storeid::StoreIdIterator;
use libimagentrylink::internal::InternalLinker;
use libimagentryutil::isa::Is;


@@ 36,8 35,6 @@ use failure::ResultExt;
use failure::Error;
use failure::err_msg;

use module_path::ModuleEntryPath;

pub trait Annotateable {
    fn annotate<'a>(&mut self, store: &'a Store) -> Result<FileLockEntry<'a>>;
    fn denotate<'a>(&mut self, store: &'a Store, ann_name: &str) -> Result<Option<FileLockEntry<'a>>>;


@@ 54,7 51,7 @@ impl Annotateable for Entry {
        let ann_name = Uuid::new_v4().to_hyphenated().to_string();
        debug!("Creating annotation with name = {}", ann_name);

        store.retrieve(ModuleEntryPath::new(ann_name.clone()).into_storeid()?)
        store.retrieve(::module_path::new_id(ann_name.clone())?)
            .and_then(|mut anno| {
                {
                    let _ = anno.set_isflag::<IsAnnotation>()?;


@@ 76,7 73,7 @@ impl Annotateable for Entry {
    // Fails if there's no such annotation entry or if the link to that annotation entry does not
    // exist.
    fn denotate<'a>(&mut self, store: &'a Store, ann_name: &str) -> Result<Option<FileLockEntry<'a>>> {
        if let Some(mut annotation) = store.get(ModuleEntryPath::new(ann_name).into_storeid()?)? {
        if let Some(mut annotation) = store.get(::module_path::new_id(ann_name)?)? {
            let _ = self.remove_internal_link(&mut annotation)?;
            Ok(Some(annotation))
        } else {

M lib/entry/libimagentrycategory/src/lib.rs => lib/entry/libimagentrycategory/src/lib.rs +1 -1
@@ 41,7 41,7 @@ extern crate toml_query;
extern crate toml;
#[macro_use]
extern crate log;
extern crate failure;
#[macro_use] extern crate failure;

extern crate libimagerror;
#[macro_use] extern crate libimagstore;

M lib/entry/libimagentrycategory/src/store.rs => lib/entry/libimagentrycategory/src/store.rs +6 -12
@@ 17,8 17,6 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//

use std::path::PathBuf;

use toml_query::insert::TomlValueInsertExt;
use toml_query::read::TomlValueReadTypeExt;
use toml::Value;


@@ 60,7 58,7 @@ impl CategoryStore for Store {
    /// Check whether a category exists
    fn category_exists(&self, name: &str) -> Result<bool> {
        trace!("Category exists? '{}'", name);
        let sid = mk_category_storeid(self.path().clone(), name)?;
        let sid = mk_category_storeid(name)?;
        represents_category(self, sid, name)
    }



@@ 69,7 67,7 @@ impl CategoryStore for Store {
    /// Fails if the category already exists (returns false then)
    fn create_category<'a>(&'a self, name: &str) -> Result<FileLockEntry<'a>> {
        trace!("Creating category: '{}'", name);
        let sid         = mk_category_storeid(self.path().clone(), name)?;
        let sid         = mk_category_storeid(name)?;
        let mut entry   = self.create(sid)?;

        entry.set_isflag::<IsCategory>()?;


@@ 90,7 88,7 @@ impl CategoryStore for Store {
        use category::Category;

        trace!("Deleting category: '{}'", name);
        let sid = mk_category_storeid(self.path().clone(), name)?;
        let sid = mk_category_storeid(name)?;

        {
            let mut category = self.get(sid.clone())?


@@ 118,7 116,7 @@ impl CategoryStore for Store {
    /// like a normal file in the store (which is exactly what it is).
    fn get_category_by_name(&self, name: &str) -> Result<Option<FileLockEntry>> {
        trace!("Getting category by name: '{}'", name);
        let sid = mk_category_storeid(self.path().clone(), name)?;
        let sid = mk_category_storeid(name)?;

        self.get(sid)
            .context(err_msg("Store write error"))


@@ 209,12 207,8 @@ mod tests {
}

#[inline]
fn mk_category_storeid(base: PathBuf, s: &str) -> Result<StoreId> {
    use libimagstore::storeid::IntoStoreId;
    ::module_path::ModuleEntryPath::new(s)
        .into_storeid()
        .context(err_msg("Store id handling error"))
        .map_err(Error::from)
fn mk_category_storeid(s: &str) -> Result<StoreId> {
    ::module_path::new_id(s).context(err_msg("Store id handling error")).map_err(Error::from)
}

#[inline]

M lib/entry/libimagentrylink/src/external.rs => lib/entry/libimagentrylink/src/external.rs +4 -8
@@ 37,7 37,6 @@ use std::fmt::Debug;
use libimagstore::store::Entry;
use libimagstore::store::Store;
use libimagstore::storeid::StoreId;
use libimagstore::storeid::IntoStoreId;
use libimagutil::debug_result::*;
use libimagerror::errors::ErrorMsg as EM;



@@ 50,7 49,6 @@ use failure::ResultExt;
use failure::err_msg;

use internal::InternalLinker;
use module_path::ModuleEntryPath;

use self::iter::*;



@@ 337,12 335,10 @@ impl ExternalLinker for Entry {
        debug!("Iterating {} links = {:?}", links.len(), links);
        links.into_iter().map(|link| {
            let hash = hex::encode(Sha1::digest(&link.as_str().as_bytes()));
            let file_id =
                ModuleEntryPath::new(format!("external/{}", hash)).into_storeid()
                    .map_dbg_err(|_| {
                        format!("Failed to build StoreId for this hash '{:?}'", hash)
                    })
                ?;
            let file_id = ::module_path::new_id(format!("external/{}", hash))
                .map_dbg_err(|_| {
                    format!("Failed to build StoreId for this hash '{:?}'", hash)
                })?;

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

M lib/entry/libimagentrylink/src/lib.rs => lib/entry/libimagentrylink/src/lib.rs +1 -1
@@ 44,8 44,8 @@ extern crate toml_query;
extern crate url;
extern crate sha1;
extern crate hex;
#[macro_use] extern crate is_match;
#[macro_use] extern crate failure;
#[macro_use] extern crate is_match;

#[cfg(test)]
extern crate env_logger;