From 88f6086c9778288272cd3142a68871df57909a60 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 28 Jan 2016 20:59:43 +0100 Subject: [PATCH 1/4] Add dep: log = 0.3.5 --- libimagstore/Cargo.toml | 1 + libimagstore/src/lib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/libimagstore/Cargo.toml b/libimagstore/Cargo.toml index e561d15e..7969b701 100644 --- a/libimagstore/Cargo.toml +++ b/libimagstore/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" authors = ["Matthias Beyer "] [dependencies] +log = "0.3.5" fs2 = "0.2.2" glob = "0.2.10" regex = "0.1.47" diff --git a/libimagstore/src/lib.rs b/libimagstore/src/lib.rs index a8044b3b..b0fb2286 100644 --- a/libimagstore/src/lib.rs +++ b/libimagstore/src/lib.rs @@ -1,4 +1,5 @@ #[macro_use] extern crate version; +#[macro_use] extern crate log; extern crate fs2; extern crate glob; extern crate regex; From 2c398d941bc8168947ab130f622f315446368c42 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 28 Jan 2016 21:00:13 +0100 Subject: [PATCH 2/4] Let LazyFile derive Debug --- libimagstore/src/lazyfile.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libimagstore/src/lazyfile.rs b/libimagstore/src/lazyfile.rs index 988639c5..27259d6e 100644 --- a/libimagstore/src/lazyfile.rs +++ b/libimagstore/src/lazyfile.rs @@ -9,6 +9,7 @@ use std::fs::{File, OpenOptions}; * * A lazy file is either absent, but a path to it is available, or it is present. */ +#[derive(Debug)] pub enum LazyFile { Absent(PathBuf), File(File) From 4bc905c692915b5cbcd696e67041245a55ea5f27 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 28 Jan 2016 21:00:33 +0100 Subject: [PATCH 3/4] Add debug output for LazyFile::{get_file_mut,create_file}() --- libimagstore/src/lazyfile.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libimagstore/src/lazyfile.rs b/libimagstore/src/lazyfile.rs index 27259d6e..b613ad91 100644 --- a/libimagstore/src/lazyfile.rs +++ b/libimagstore/src/lazyfile.rs @@ -53,6 +53,7 @@ impl LazyFile { * Get the mutable file behind a LazyFile object */ pub fn get_file_mut(&mut self) -> Result<&mut File, StoreError> { + debug!("Getting lazy file: {:?}", self); let file = match *self { LazyFile::File(ref mut f) => return { // We seek to the beginning of the file since we expect each @@ -80,6 +81,7 @@ impl LazyFile { * Create a file out of this LazyFile object */ pub fn create_file(&mut self) -> Result<&mut File, StoreError> { + debug!("Creating lazy file: {:?}", self); let file = match *self { LazyFile::File(ref mut f) => return Ok(f), LazyFile::Absent(ref p) => { From b04c676eb98c9380ed422ef1b0fd4d930dd65ea2 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 28 Jan 2016 21:06:49 +0100 Subject: [PATCH 4/4] Add store debugging output --- libimagstore/src/store.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index e8fbbb98..f7c0ab64 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -103,18 +103,23 @@ impl Store { pub fn new(location: PathBuf) -> Result { use std::fs::create_dir_all; + debug!("Building new Store object"); if !location.exists() { + debug!("Creating store path"); let c = create_dir_all(location.clone()); if c.is_err() { + debug!("Failed"); return Err(StoreError::new(StoreErrorKind::StorePathCreate, Some(Box::new(c.err().unwrap())))); } } else { if location.is_file() { + debug!("Store path exists as file"); return Err(StoreError::new(StoreErrorKind::StorePathExists, None)); } } + debug!("Store building succeeded"); Ok(Store { location: location, entries: Arc::new(RwLock::new(HashMap::new())), @@ -218,6 +223,7 @@ impl Drop for Store { * TODO: Unlock them */ fn drop(&mut self) { + debug!("Dropping store"); } } @@ -400,6 +406,7 @@ impl Entry { } pub fn from_str(loc: StoreId, s: &str) -> Result { + debug!("Building entry from string"); let re = Regex::new(r"(?smx) ^---$ (?P
.*) # Header @@ -422,6 +429,7 @@ impl Entry { return Err(StoreError::new(StoreErrorKind::MalformedEntry, None)); } + debug!("Header and content found. Yay! Building Entry object now"); Ok(Entry { location: loc, header: try!(EntryHeader::parse(header.unwrap())),