diff --git a/plugins/store/src/store.rs b/plugins/store/src/store.rs index b18d002773..d610525d3c 100644 --- a/plugins/store/src/store.rs +++ b/plugins/store/src/store.rs @@ -437,6 +437,9 @@ impl Store { } pub fn save(&self) -> crate::Result<()> { + if let Some(sender) = self.auto_save_debounce_sender.lock().unwrap().take() { + let _ = sender.send(AutoSaveMessage::Cancel); + } self.store.lock().unwrap().save(self.serialize) } @@ -467,8 +470,8 @@ impl Store { } } _ = sleep(auto_save_delay) => { - let _ = store.lock().unwrap().save(serialize_fn); auto_save_debounce_sender.lock().unwrap().take(); + let _ = store.lock().unwrap().save(serialize_fn); return; } }; @@ -477,12 +480,3 @@ impl Store { Ok(()) } } - -impl Drop for Store { - fn drop(&mut self) { - let auto_save_debounce_sender = self.auto_save_debounce_sender.lock().unwrap(); - if let Some(ref sender) = *auto_save_debounce_sender { - let _ = sender.send(AutoSaveMessage::Cancel); - } - } -}