diff --git a/plugins/store/guest-js/index.ts b/plugins/store/guest-js/index.ts index 598a33e9..c9df7a31 100644 --- a/plugins/store/guest-js/index.ts +++ b/plugins/store/guest-js/index.ts @@ -26,7 +26,7 @@ export type StoreOptions = { * @param path: Path to save the store in `app_data_dir` * @param options: Store configuration options * - * Throws if the store at that path already exists + * @throws If a store at that path already exists */ export async function createStore( path: string, diff --git a/plugins/store/src/store.rs b/plugins/store/src/store.rs index 6e363c33..c6c99558 100644 --- a/plugins/store/src/store.rs +++ b/plugins/store/src/store.rs @@ -463,6 +463,18 @@ impl Store { self.store.lock().unwrap().save() } + pub fn close_store(self) { + let store = self.store.lock().unwrap(); + let app = store.app.clone(); + let collection = app.state::(); + let stores = collection.stores.lock().unwrap(); + if let Some(rid) = stores.get(&store.path).copied() { + drop(store); + drop(stores); + let _ = app.resources_table().take::>(rid); + } + } + fn trigger_auto_save(&self) -> crate::Result<()> { let Some(auto_save_delay) = self.auto_save else { return Ok(());