summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-05-02 18:39:11 +0200
committerGitHub <noreply@github.com>2018-05-02 18:39:11 +0200
commiteb20a9d881eb801ff794d7b0d20e2a012d2f9094 (patch)
treef3c5b9216c9de8df3a3da9f3f28d0d90998ef6ce /lib
parentb52cb0d69765ac216252e0d30727512454ca2511 (diff)
parent0dbef993c102598f5d58a04e40bb6204d2ab4839 (diff)
Merge pull request #1477 from matthiasbeyer/libimagstore/remove-walk
Remove Store::walk()
Diffstat (limited to 'lib')
-rw-r--r--lib/core/libimagstore/src/store.rs80
1 files changed, 2 insertions, 78 deletions
diff --git a/lib/core/libimagstore/src/store.rs b/lib/core/libimagstore/src/store.rs
index cefa42d7..e85b65f4 100644
--- a/lib/core/libimagstore/src/store.rs
+++ b/lib/core/libimagstore/src/store.rs
@@ -32,8 +32,6 @@ use std::fmt::Debug;
use std::fmt::Error as FMTError;
use toml::Value;
-use walkdir::WalkDir;
-use walkdir::Iter as WalkDirIter;
use toml_query::read::TomlValueReadExt;
use toml_query::read::TomlValueReadTypeExt;
@@ -47,7 +45,6 @@ pub use file_abstraction::FileAbstraction;
pub use file_abstraction::FSFileAbstraction;
pub use file_abstraction::InMemoryFileAbstraction;
-use libimagerror::trace::trace_error;
use libimagutil::debug_result::*;
/// The Result Type returned by any interaction with the store that could fail
@@ -69,72 +66,6 @@ struct StoreEntry {
status: StoreEntryStatus,
}
-pub enum StoreObject {
- Id(StoreId),
- Collection(PathBuf),
-}
-
-pub struct Walk {
- store_path: PathBuf,
- dirwalker: WalkDirIter,
-}
-
-impl Walk {
-
- fn new(mut store_path: PathBuf, mod_name: &str) -> Walk {
- let pb = store_path.clone();
- store_path.push(mod_name);
- Walk {
- store_path: pb,
- dirwalker: WalkDir::new(store_path).into_iter(),
- }
- }
-}
-
-impl ::std::ops::Deref for Walk {
- type Target = WalkDirIter;
-
- fn deref(&self) -> &Self::Target {
- &self.dirwalker
- }
-}
-
-impl Iterator for Walk {
- type Item = StoreObject;
-
- fn next(&mut self) -> Option<Self::Item> {
-
- while let Some(something) = self.dirwalker.next() {
- debug!("[Walk] Processing next item: {:?}", something);
- match something {
- Ok(next) => if next.file_type().is_dir() {
- debug!("Found directory...");
- return Some(StoreObject::Collection(next.path().to_path_buf()))
- } else /* if next.file_type().is_file() */ {
- debug!("Found file...");
- let n = next.path().to_path_buf();
- let sid = match StoreId::from_full_path(&self.store_path, n) {
- Err(e) => {
- debug!("Could not construct StoreId object from it");
- trace_error(&e);
- continue;
- },
- Ok(o) => o,
- };
- return Some(StoreObject::Id(sid))
- },
- Err(e) => {
- warn!("Error in Walker");
- debug!("{:?}", e);
- return None;
- }
- }
- }
-
- None
- }
-}
-
impl StoreEntry {
fn new(id: StoreId, backend: &Arc<FileAbstraction>) -> Result<StoreEntry> {
@@ -396,15 +327,6 @@ impl Store {
self.retrieve(id.clone()).map(Some).chain_err(|| SEK::GetCallError(id))
}
- /// Walk the store tree for the module
- ///
- /// The difference between a `Walk` and a `StoreIdIterator` is that with a `Walk`, one can find
- /// "collections" (folders).
- pub fn walk<'a>(&'a self, mod_name: &str) -> Walk {
- debug!("Creating Walk object for {}", mod_name);
- Walk::new(self.path().clone(), mod_name)
- }
-
/// Write (update) the `FileLockEntry` to disk
///
/// # Return value
@@ -813,6 +735,8 @@ impl<'a> Drop for FileLockEntry<'a> {
/// This will not silently ignore errors but prints the result of the _update() call for testing
fn drop(&mut self) {
+ use libimagerror::trace::trace_error;
+
trace!("Dropping: {:?} - from FileLockEntry::drop() (test impl)", self.get_location());
let _ = self.store._update(self, true).map_err(|e| trace_error(&e));
}