Revert "Add get-or-create-store"

This reverts commit 7ffd769240.
pull/1860/head
Tony 8 months ago
parent 7ffd769240
commit 3acf66ee57
No known key found for this signature in database
GPG Key ID: 34BDD3EA27824956

@ -5,7 +5,6 @@
const COMMANDS: &[&str] = &[
"create_store",
"get_store",
"get_or_create_store",
"set",
"get",
"has",

@ -42,17 +42,6 @@ export async function getStore(path: string): Promise<Store | undefined> {
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<Store> {
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<Store> {
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<Store> {
const resourceId = await invoke<number>(
'plugin:store|get_or_create_store',
{
path,
...options
}
)
return new Store(resourceId, path)
}
async set(key: string, value: unknown): Promise<void> {
await invoke('plugin:store|set', {
rid: this.rid,

@ -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"]

@ -165,32 +165,6 @@ Denies the get command without any pre-configured scope.
<tr>
<td>
`store:allow-get-or-create-store`
</td>
<td>
Enables the get_or_create_store command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`store:deny-get-or-create-store`
</td>
<td>
Denies the get_or_create_store command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`store:allow-get-store`
</td>

@ -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",

@ -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",

@ -77,19 +77,6 @@ async fn get_store<R: Runtime>(app: AppHandle<R>, path: PathBuf) -> Option<Resou
stores.get(&path).copied()
}
#[tauri::command]
async fn get_or_create_store<R: Runtime>(
app: AppHandle<R>,
path: PathBuf,
auto_save: Option<AutoSave>,
) -> Result<ResourceId> {
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<R: Runtime>(
app: AppHandle<R>,
@ -245,7 +232,6 @@ impl<R: Runtime> Builder<R> {
.invoke_handler(tauri::generate_handler![
create_store,
get_store,
get_or_create_store,
set,
get,
has,

Loading…
Cancel
Save