Add store debugging output
This commit is contained in:
parent
4bc905c692
commit
b04c676eb9
1 changed files with 8 additions and 0 deletions
|
@ -103,18 +103,23 @@ impl Store {
|
||||||
pub fn new(location: PathBuf) -> Result<Store> {
|
pub fn new(location: PathBuf) -> Result<Store> {
|
||||||
use std::fs::create_dir_all;
|
use std::fs::create_dir_all;
|
||||||
|
|
||||||
|
debug!("Building new Store object");
|
||||||
if !location.exists() {
|
if !location.exists() {
|
||||||
|
debug!("Creating store path");
|
||||||
let c = create_dir_all(location.clone());
|
let c = create_dir_all(location.clone());
|
||||||
if c.is_err() {
|
if c.is_err() {
|
||||||
|
debug!("Failed");
|
||||||
return Err(StoreError::new(StoreErrorKind::StorePathCreate,
|
return Err(StoreError::new(StoreErrorKind::StorePathCreate,
|
||||||
Some(Box::new(c.err().unwrap()))));
|
Some(Box::new(c.err().unwrap()))));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if location.is_file() {
|
if location.is_file() {
|
||||||
|
debug!("Store path exists as file");
|
||||||
return Err(StoreError::new(StoreErrorKind::StorePathExists, None));
|
return Err(StoreError::new(StoreErrorKind::StorePathExists, None));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug!("Store building succeeded");
|
||||||
Ok(Store {
|
Ok(Store {
|
||||||
location: location,
|
location: location,
|
||||||
entries: Arc::new(RwLock::new(HashMap::new())),
|
entries: Arc::new(RwLock::new(HashMap::new())),
|
||||||
|
@ -218,6 +223,7 @@ impl Drop for Store {
|
||||||
* TODO: Unlock them
|
* TODO: Unlock them
|
||||||
*/
|
*/
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
|
debug!("Dropping store");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -400,6 +406,7 @@ impl Entry {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_str(loc: StoreId, s: &str) -> Result<Entry> {
|
pub fn from_str(loc: StoreId, s: &str) -> Result<Entry> {
|
||||||
|
debug!("Building entry from string");
|
||||||
let re = Regex::new(r"(?smx)
|
let re = Regex::new(r"(?smx)
|
||||||
^---$
|
^---$
|
||||||
(?P<header>.*) # Header
|
(?P<header>.*) # Header
|
||||||
|
@ -422,6 +429,7 @@ impl Entry {
|
||||||
return Err(StoreError::new(StoreErrorKind::MalformedEntry, None));
|
return Err(StoreError::new(StoreErrorKind::MalformedEntry, None));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug!("Header and content found. Yay! Building Entry object now");
|
||||||
Ok(Entry {
|
Ok(Entry {
|
||||||
location: loc,
|
location: loc,
|
||||||
header: try!(EntryHeader::parse(header.unwrap())),
|
header: try!(EntryHeader::parse(header.unwrap())),
|
||||||
|
|
Loading…
Reference in a new issue