diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-03-20 11:55:27 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-03-20 11:55:27 -0400 |
commit | 84e912b7779faaaeb09d1085e09630a548c7fb54 (patch) | |
tree | 662665d1b7f1401ac9259bd6fa12e5e6aa2890ec /src/history.rs | |
parent | bd779fc6df4641f81bbbfe50663d883d64a5c88e (diff) |
Add more reloading triggers
Diffstat (limited to 'src/history.rs')
-rw-r--r-- | src/history.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/history.rs b/src/history.rs index 5abb78b..f4a0391 100644 --- a/src/history.rs +++ b/src/history.rs @@ -20,6 +20,7 @@ pub trait DirectoryHistory { path: &Path, sort_option: &sort::SortOption, ) -> std::io::Result<()>; + fn reload(&mut self, path: &Path, sort_option: &sort::SortOption) -> std::io::Result<()>; fn depreciate_all_entries(&mut self); fn depreciate_entry(&mut self, path: &Path); @@ -99,6 +100,17 @@ impl DirectoryHistory for JoshutoHistory { Ok(()) } + fn reload(&mut self, path: &Path, sort_option: &sort::SortOption) -> std::io::Result<()> { + match self.entry(path.to_path_buf()) { + Entry::Occupied(mut entry) => { + let dirlist = entry.get_mut(); + dirlist.reload_contents(sort_option)?; + } + Entry::Vacant(entry) => {} + } + Ok(()) + } + fn depreciate_all_entries(&mut self) { self.iter_mut().for_each(|(_, v)| v.depreciate()); } |