diff --git a/plugins/store/build.rs b/plugins/store/build.rs index 5d30417d..a144df29 100644 --- a/plugins/store/build.rs +++ b/plugins/store/build.rs @@ -5,7 +5,6 @@ const COMMANDS: &[&str] = &[ "create_store", "get_store", - "get_or_create_store", "set", "get", "has", diff --git a/plugins/store/guest-js/index.ts b/plugins/store/guest-js/index.ts index d21ce45c..2c2be476 100644 --- a/plugins/store/guest-js/index.ts +++ b/plugins/store/guest-js/index.ts @@ -42,17 +42,6 @@ export async function getStore(path: string): Promise { return await Store.getStore(path) } -/** - * @param path: Path to save the store in `app_data_dir` - * @param options: Store configuration options - */ -export async function getOrCreateStore( - path: string, - options?: StoreOptions -): Promise { - return await Store.getOrCreateStore(path, options) -} - /** * A lazy loaded key-value store persisted by the backend layer. * @@ -67,7 +56,9 @@ export class LazyStore implements IStore { private get store(): Promise { if (!this._store) { - this._store = getOrCreateStore(this.path, this.options) + this._store = createStore(this.path, this.options).catch( + async () => (await getStore(this.path))! + ) } return this._store } @@ -183,24 +174,6 @@ export class Store extends Resource implements IStore { return resourceId ? new Store(resourceId, path) : undefined } - /** - * @param path: Path to save the store in `app_data_dir` - * @param options: Store configuration options - */ - static async getOrCreateStore( - path: string, - options?: StoreOptions - ): Promise { - const resourceId = await invoke( - 'plugin:store|get_or_create_store', - { - path, - ...options - } - ) - return new Store(resourceId, path) - } - async set(key: string, value: unknown): Promise { await invoke('plugin:store|set', { rid: this.rid, diff --git a/plugins/store/permissions/autogenerated/commands/get_or_create_store.toml b/plugins/store/permissions/autogenerated/commands/get_or_create_store.toml deleted file mode 100644 index 73f12fd7..00000000 --- a/plugins/store/permissions/autogenerated/commands/get_or_create_store.toml +++ /dev/null @@ -1,13 +0,0 @@ -# Automatically generated - DO NOT EDIT! - -"$schema" = "../../schemas/schema.json" - -[[permission]] -identifier = "allow-get-or-create-store" -description = "Enables the get_or_create_store command without any pre-configured scope." -commands.allow = ["get_or_create_store"] - -[[permission]] -identifier = "deny-get-or-create-store" -description = "Denies the get_or_create_store command without any pre-configured scope." -commands.deny = ["get_or_create_store"] diff --git a/plugins/store/permissions/autogenerated/reference.md b/plugins/store/permissions/autogenerated/reference.md index 203bdc7a..ce857346 100644 --- a/plugins/store/permissions/autogenerated/reference.md +++ b/plugins/store/permissions/autogenerated/reference.md @@ -165,32 +165,6 @@ Denies the get command without any pre-configured scope. -`store:allow-get-or-create-store` - - - - -Enables the get_or_create_store command without any pre-configured scope. - - - - - - - -`store:deny-get-or-create-store` - - - - -Denies the get_or_create_store command without any pre-configured scope. - - - - - - - `store:allow-get-store` diff --git a/plugins/store/permissions/default.toml b/plugins/store/permissions/default.toml index 225a4b26..bf888679 100644 --- a/plugins/store/permissions/default.toml +++ b/plugins/store/permissions/default.toml @@ -12,8 +12,6 @@ All operations are enabled by default. """ permissions = [ "allow-create-store", - "allow-get-store", - "allow-get-or-create-store", "allow-clear", "allow-delete", "allow-entries", diff --git a/plugins/store/permissions/schemas/schema.json b/plugins/store/permissions/schemas/schema.json index 69ef4f64..bfd50f9c 100644 --- a/plugins/store/permissions/schemas/schema.json +++ b/plugins/store/permissions/schemas/schema.json @@ -344,16 +344,6 @@ "type": "string", "const": "deny-get" }, - { - "description": "Enables the get_or_create_store command without any pre-configured scope.", - "type": "string", - "const": "allow-get-or-create-store" - }, - { - "description": "Denies the get_or_create_store command without any pre-configured scope.", - "type": "string", - "const": "deny-get-or-create-store" - }, { "description": "Enables the get_store command without any pre-configured scope.", "type": "string", diff --git a/plugins/store/src/lib.rs b/plugins/store/src/lib.rs index ac444aef..532ee1ab 100644 --- a/plugins/store/src/lib.rs +++ b/plugins/store/src/lib.rs @@ -77,19 +77,6 @@ async fn get_store(app: AppHandle, path: PathBuf) -> Option( - app: AppHandle, - path: PathBuf, - auto_save: Option, -) -> Result { - if let Some(rid) = get_store(app.clone(), path.clone()).await { - Ok(rid) - } else { - create_store(app, path, auto_save).await - } -} - #[tauri::command] async fn set( app: AppHandle, @@ -245,7 +232,6 @@ impl Builder { .invoke_handler(tauri::generate_handler![ create_store, get_store, - get_or_create_store, set, get, has,