summaryrefslogtreecommitdiffstats
path: root/src/history.rs
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2019-02-20 19:51:06 -0500
committerJiayi Zhao <jeff.no.zhao@gmail.com>2019-02-20 19:51:54 -0500
commitf75182734a5bec0987b424aff28e2ed0acf2fe38 (patch)
treecb483f5a020057f1856fcf6c507337be6775f2bf /src/history.rs
parentc829e7849a44922cb55149f3874a82cda1040c89 (diff)
reduce eprintln
Diffstat (limited to 'src/history.rs')
-rw-r--r--src/history.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/history.rs b/src/history.rs
index fc69338..78e3b64 100644
--- a/src/history.rs
+++ b/src/history.rs
@@ -29,7 +29,7 @@ impl DirHistory {
}
self.map.insert(curr.to_path_buf(), s);
}
- Err(e) => eprintln!("{}", e),
+ Err(e) => eprintln!("populate_to_root: {}", e),
};
ancestor = curr;
}
@@ -59,7 +59,7 @@ impl DirHistory {
&mut self,
path: &Path,
sort_type: &sort::SortType,
- ) -> Option<&mut structs::JoshutoDirList> {
+ ) -> Result<&mut structs::JoshutoDirList, std::io::Error> {
let pathbuf = path.to_path_buf();
match self.map.entry(pathbuf.clone()) {
Entry::Occupied(mut entry) => {
@@ -69,12 +69,17 @@ impl DirHistory {
}
}
Entry::Vacant(entry) => {
- if let Ok(s) = structs::JoshutoDirList::new(path.to_path_buf(), &sort_type) {
- entry.insert(s);
- }
+ let s = structs::JoshutoDirList::new(path.to_path_buf(), &sort_type)?;
+ entry.insert(s);
}
};
- self.map.get_mut(&pathbuf)
+ match self.map.get_mut(&pathbuf) {
+ Some(s) => Ok(s),
+ None => Err(std::io::Error::new(
+ std::io::ErrorKind::NotFound,
+ "Can't find file",
+ )),
+ }
}
pub fn put_back(&mut self, dirlist: Option<structs::JoshutoDirList>) {