Move Update-Hook execution into Store._update()
This commit is contained in:
parent
8f01cf15e4
commit
3252f9b751
1 changed files with 16 additions and 16 deletions
|
@ -493,21 +493,10 @@ impl Store {
|
||||||
|
|
||||||
/// Return the `FileLockEntry` and write to disk
|
/// Return the `FileLockEntry` and write to disk
|
||||||
pub fn update<'a>(&'a self, mut entry: FileLockEntry<'a>) -> Result<()> {
|
pub fn update<'a>(&'a self, mut entry: FileLockEntry<'a>) -> Result<()> {
|
||||||
if let Err(e) = self.execute_hooks_for_mut_file(self.pre_update_aspects.clone(), &mut entry) {
|
if let Err(e) = self._update(&mut entry) {
|
||||||
return Err(e)
|
|
||||||
.map_err_into(SEK::PreHookExecuteError)
|
|
||||||
.map_err_into(SEK::HookExecutionError)
|
|
||||||
.map_err_into(SEK::UpdateCallError);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Err(e) = self._update(&entry) {
|
|
||||||
return Err(e).map_err_into(SEK::UpdateCallError);
|
return Err(e).map_err_into(SEK::UpdateCallError);
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
self.execute_hooks_for_mut_file(self.post_update_aspects.clone(), &mut entry)
|
|
||||||
.map_err_into(SEK::PostHookExecuteError)
|
|
||||||
.map_err_into(SEK::HookExecutionError)
|
|
||||||
.map_err_into(SEK::UpdateCallError)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Internal method to write to the filesystem store.
|
/// Internal method to write to the filesystem store.
|
||||||
|
@ -515,7 +504,14 @@ impl Store {
|
||||||
/// # Assumptions
|
/// # Assumptions
|
||||||
/// This method assumes that entry is dropped _right after_ the call, hence
|
/// This method assumes that entry is dropped _right after_ the call, hence
|
||||||
/// it is not public.
|
/// it is not public.
|
||||||
fn _update<'a>(&'a self, entry: &FileLockEntry<'a>) -> Result<()> {
|
fn _update<'a>(&'a self, entry: &mut FileLockEntry<'a>) -> Result<()> {
|
||||||
|
if let Err(e) = self.execute_hooks_for_mut_file(self.pre_update_aspects.clone(), entry) {
|
||||||
|
return Err(e)
|
||||||
|
.map_err_into(SEK::PreHookExecuteError)
|
||||||
|
.map_err_into(SEK::HookExecutionError)
|
||||||
|
.map_err_into(SEK::UpdateCallError);
|
||||||
|
}
|
||||||
|
|
||||||
let mut hsmap = match self.entries.write() {
|
let mut hsmap = match self.entries.write() {
|
||||||
Err(_) => return Err(SE::new(SEK::LockPoisoned, None)),
|
Err(_) => return Err(SE::new(SEK::LockPoisoned, None)),
|
||||||
Ok(e) => e,
|
Ok(e) => e,
|
||||||
|
@ -532,7 +528,11 @@ impl Store {
|
||||||
try!(se.write_entry(&entry.entry));
|
try!(se.write_entry(&entry.entry));
|
||||||
se.status = StoreEntryStatus::Present;
|
se.status = StoreEntryStatus::Present;
|
||||||
|
|
||||||
Ok(())
|
|
||||||
|
self.execute_hooks_for_mut_file(self.post_update_aspects.clone(), entry)
|
||||||
|
.map_err_into(SEK::PostHookExecuteError)
|
||||||
|
.map_err_into(SEK::HookExecutionError)
|
||||||
|
.map_err_into(SEK::UpdateCallError)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieve a copy of a given entry, this cannot be used to mutate
|
/// Retrieve a copy of a given entry, this cannot be used to mutate
|
||||||
|
@ -865,7 +865,7 @@ impl<'a> DerefMut for FileLockEntry<'a> {
|
||||||
impl<'a> Drop for FileLockEntry<'a> {
|
impl<'a> Drop for FileLockEntry<'a> {
|
||||||
/// This will silently ignore errors, use `Store::update` if you want to catch the errors
|
/// This will silently ignore errors, use `Store::update` if you want to catch the errors
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let _ = self.store._update(self);
|
let _ = self.store._update(self).map_err(|e| trace_error(&e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue