Compare commits

...

9 Commits

Author SHA1 Message Date
amrbashir bc53cf11db use ShellExecuteExW 2024-10-30 01:55:03 +03:00
amrbashir 539d41ace7 use dunce 2024-10-30 01:38:01 +03:00
amrbashir 1ec8844b0e lock file 2024-10-30 00:37:30 +03:00
amrbashir b5c55d4ba2 Merge branch 'v2' into feat/shell-show-item-in-dir 2024-10-30 00:37:20 +03:00
阿良仔 4341d7f500 fix(sql): replace Mutex with RwLock to enable concurrent SQL execution (#1972) 2024-10-26 13:19:59 +02:00
Amr Bashir 77149dc432 fix(fs): fix writeFile converting UTF-8 characters in path into replacement character (#1965) 2024-10-22 08:17:37 +03:00
github-actions[bot] 525abc4be5 Publish New Versions (v2) (#1961)
Co-authored-by: amrbashir <amrbashir@users.noreply.github.com>
2024-10-21 15:13:27 +03:00
bWanShiTong 14cee64c82 fix(fs): fix compilation on targets with pointer width 16 and 32 (#1958) 2024-10-21 15:07:55 +03:00
amrbashir 5092683f97 feat(shell): add show_item_in_dir api 2024-02-28 03:25:18 +02:00
24 changed files with 224 additions and 33 deletions
+5
View File
@@ -0,0 +1,5 @@
---
sql: patch
---
Replace `Mutex` with `RwLock` to enable concurrent SQL execution.
+5
View File
@@ -0,0 +1,5 @@
---
"fs-js": "patch"
---
Fix `writeTextFile` converting UTF-8 characters (for example `äöü`) in the given path into replacement character (``)
Generated
+27 -5
View File
@@ -218,7 +218,7 @@ checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6"
[[package]] [[package]]
name = "api" name = "api"
version = "2.0.3" version = "2.0.4"
dependencies = [ dependencies = [
"log", "log",
"serde", "serde",
@@ -6825,7 +6825,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-dialog" name = "tauri-plugin-dialog"
version = "2.0.2" version = "2.0.3"
dependencies = [ dependencies = [
"log", "log",
"raw-window-handle", "raw-window-handle",
@@ -6841,7 +6841,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-fs" name = "tauri-plugin-fs"
version = "2.0.2" version = "2.0.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"dunce", "dunce",
@@ -6901,7 +6901,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-http" name = "tauri-plugin-http"
version = "2.0.2" version = "2.0.3"
dependencies = [ dependencies = [
"data-url", "data-url",
"http", "http",
@@ -7005,7 +7005,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-persisted-scope" name = "tauri-plugin-persisted-scope"
version = "2.0.2" version = "2.0.3"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"bincode", "bincode",
@@ -7042,6 +7042,7 @@ dependencies = [
name = "tauri-plugin-shell" name = "tauri-plugin-shell"
version = "2.0.2" version = "2.0.2"
dependencies = [ dependencies = [
"dunce",
"encoding_rs", "encoding_rs",
"log", "log",
"open", "open",
@@ -7055,6 +7056,7 @@ dependencies = [
"tauri-plugin", "tauri-plugin",
"thiserror", "thiserror",
"tokio", "tokio",
"windows 0.54.0",
] ]
[[package]] [[package]]
@@ -8344,6 +8346,16 @@ dependencies = [
"windows_x86_64_msvc 0.36.1", "windows_x86_64_msvc 0.36.1",
] ]
[[package]]
name = "windows"
version = "0.54.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49"
dependencies = [
"windows-core 0.54.0",
"windows-targets 0.52.6",
]
[[package]] [[package]]
name = "windows" name = "windows"
version = "0.56.0" version = "0.56.0"
@@ -8373,6 +8385,16 @@ dependencies = [
"windows-targets 0.52.6", "windows-targets 0.52.6",
] ]
[[package]]
name = "windows-core"
version = "0.54.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65"
dependencies = [
"windows-result 0.1.2",
"windows-targets 0.52.6",
]
[[package]] [[package]]
name = "windows-core" name = "windows-core"
version = "0.56.0" version = "0.56.0"
+8
View File
@@ -1,5 +1,13 @@
# Changelog # Changelog
## \[2.0.4]
### Dependencies
- Upgraded to `fs@2.0.3`
- Upgraded to `dialog@2.0.3`
- Upgraded to `http@2.0.3`
## \[2.0.3] ## \[2.0.3]
### Dependencies ### Dependencies
+4 -4
View File
@@ -1,7 +1,7 @@
[package] [package]
name = "api" name = "api"
publish = false publish = false
version = "2.0.3" version = "2.0.4"
description = "An example Tauri Application showcasing the api" description = "An example Tauri Application showcasing the api"
edition = "2021" edition = "2021"
rust-version = { workspace = true } rust-version = { workspace = true }
@@ -20,14 +20,14 @@ serde = { workspace = true }
tiny_http = "0.12" tiny_http = "0.12"
log = { workspace = true } log = { workspace = true }
tauri-plugin-log = { path = "../../../plugins/log", version = "2.0.1" } tauri-plugin-log = { path = "../../../plugins/log", version = "2.0.1" }
tauri-plugin-fs = { path = "../../../plugins/fs", version = "2.0.2", features = [ tauri-plugin-fs = { path = "../../../plugins/fs", version = "2.0.3", features = [
"watch", "watch",
] } ] }
tauri-plugin-clipboard-manager = { path = "../../../plugins/clipboard-manager", version = "2.0.1" } tauri-plugin-clipboard-manager = { path = "../../../plugins/clipboard-manager", version = "2.0.1" }
tauri-plugin-dialog = { path = "../../../plugins/dialog", version = "2.0.2" } tauri-plugin-dialog = { path = "../../../plugins/dialog", version = "2.0.3" }
tauri-plugin-http = { path = "../../../plugins/http", features = [ tauri-plugin-http = { path = "../../../plugins/http", features = [
"multipart", "multipart",
], version = "2.0.2" } ], version = "2.0.3" }
tauri-plugin-notification = { path = "../../../plugins/notification", version = "2.0.1", features = [ tauri-plugin-notification = { path = "../../../plugins/notification", version = "2.0.1", features = [
"windows7-compat", "windows7-compat",
] } ] }
+7 -1
View File
@@ -1,5 +1,11 @@
# Changelog # Changelog
## \[2.0.3]
### Dependencies
- Upgraded to `fs@2.0.3`
## \[2.0.1] ## \[2.0.1]
- [`2302c2db`](https://github.com/tauri-apps/plugins-workspace/commit/2302c2db1c49673e61dcbda8cdb01b2c57e9ba6f) ([#1910](https://github.com/tauri-apps/plugins-workspace/pull/1910) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Fix `ask` and `confirm` not using system button texts - [`2302c2db`](https://github.com/tauri-apps/plugins-workspace/commit/2302c2db1c49673e61dcbda8cdb01b2c57e9ba6f) ([#1910](https://github.com/tauri-apps/plugins-workspace/pull/1910) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Fix `ask` and `confirm` not using system button texts
@@ -293,5 +299,5 @@
pull/371)) First v2 alpha release! pull/371)) First v2 alpha release!
lpha release! lpha release!
pull/371)) First v2 alpha release! pull/371)) First v2 alpha release!
lease! lease!
pull/371)) First v2 alpha release! pull/371)) First v2 alpha release!
+2 -2
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "tauri-plugin-dialog" name = "tauri-plugin-dialog"
version = "2.0.2" version = "2.0.3"
description = "Native system dialogs for opening and saving files along with message dialogs on your Tauri application." description = "Native system dialogs for opening and saving files along with message dialogs on your Tauri application."
edition = { workspace = true } edition = { workspace = true }
authors = { workspace = true } authors = { workspace = true }
@@ -34,7 +34,7 @@ tauri = { workspace = true }
log = { workspace = true } log = { workspace = true }
thiserror = { workspace = true } thiserror = { workspace = true }
url = { workspace = true } url = { workspace = true }
tauri-plugin-fs = { path = "../fs", version = "2.0.2" } tauri-plugin-fs = { path = "../fs", version = "2.0.3" }
[target.'cfg(target_os = "ios")'.dependencies] [target.'cfg(target_os = "ios")'.dependencies]
tauri = { workspace = true, features = ["wry"] } tauri = { workspace = true, features = ["wry"] }
+4
View File
@@ -1,5 +1,9 @@
# Changelog # Changelog
## \[2.0.3]
- [`14cee64c`](https://github.com/tauri-apps/plugins-workspace/commit/14cee64c82a72655ae6a4ac0892736a2959dbda5) ([#1958](https://github.com/tauri-apps/plugins-workspace/pull/1958) by [@bWanShiTong](https://github.com/tauri-apps/plugins-workspace/../../bWanShiTong)) Fix compilation on targets with pointer width of `16` or `32`
## \[2.0.1] ## \[2.0.1]
- [`ae802456`](https://github.com/tauri-apps/plugins-workspace/commit/ae8024565f074f313084777c8b10d1b5e3bbe220) ([#1950](https://github.com/tauri-apps/plugins-workspace/pull/1950) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Improve performance of the `FileHandle.read` and `writeTextFile` APIs. - [`ae802456`](https://github.com/tauri-apps/plugins-workspace/commit/ae8024565f074f313084777c8b10d1b5e3bbe220) ([#1950](https://github.com/tauri-apps/plugins-workspace/pull/1950) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Improve performance of the `FileHandle.read` and `writeTextFile` APIs.
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "tauri-plugin-fs" name = "tauri-plugin-fs"
version = "2.0.2" version = "2.0.3"
description = "Access the file system." description = "Access the file system."
authors = { workspace = true } authors = { workspace = true }
license = { workspace = true } license = { workspace = true }
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1072,7 +1072,7 @@ async function writeTextFile(
await invoke('plugin:fs|write_text_file', encoder.encode(data), { await invoke('plugin:fs|write_text_file', encoder.encode(data), {
headers: { headers: {
path: path instanceof URL ? path.toString() : path, path: encodeURIComponent(path instanceof URL ? path.toString() : path),
options: JSON.stringify(options) options: JSON.stringify(options)
} }
}) })
+2
View File
@@ -316,12 +316,14 @@ pub async fn read<R: Runtime>(
let nread = nread.to_be_bytes(); let nread = nread.to_be_bytes();
let mut out = [0; 8]; let mut out = [0; 8];
out[6..].copy_from_slice(&nread); out[6..].copy_from_slice(&nread);
out
}; };
#[cfg(target_pointer_width = "32")] #[cfg(target_pointer_width = "32")]
let nread = { let nread = {
let nread = nread.to_be_bytes(); let nread = nread.to_be_bytes();
let mut out = [0; 8]; let mut out = [0; 8];
out[4..].copy_from_slice(&nread); out[4..].copy_from_slice(&nread);
out
}; };
#[cfg(target_pointer_width = "64")] #[cfg(target_pointer_width = "64")]
let nread = nread.to_be_bytes(); let nread = nread.to_be_bytes();
+7 -1
View File
@@ -1,5 +1,11 @@
# Changelog # Changelog
## \[2.0.3]
### Dependencies
- Upgraded to `fs@2.0.3`
## \[2.0.1] ## \[2.0.1]
- [`cfd48b3b`](https://github.com/tauri-apps/plugins-workspace/commit/cfd48b3b2ec0fccfc162197518694ed59ceda22c) ([#1941](https://github.com/tauri-apps/plugins-workspace/pull/1941) by [@Nipsuli](https://github.com/tauri-apps/plugins-workspace/../../Nipsuli)) Allow skipping sending `Origin` header in HTTP requests by setting `Origin` header to an empty string when calling `fetch`. - [`cfd48b3b`](https://github.com/tauri-apps/plugins-workspace/commit/cfd48b3b2ec0fccfc162197518694ed59ceda22c) ([#1941](https://github.com/tauri-apps/plugins-workspace/pull/1941) by [@Nipsuli](https://github.com/tauri-apps/plugins-workspace/../../Nipsuli)) Allow skipping sending `Origin` header in HTTP requests by setting `Origin` header to an empty string when calling `fetch`.
@@ -291,6 +297,6 @@
ha release! ha release!
! !
371\)) First v2 alpha release! 371\)) First v2 alpha release!
lease! lease!
! !
371\)) First v2 alpha release! 371\)) First v2 alpha release!
+2 -2
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "tauri-plugin-http" name = "tauri-plugin-http"
version = "2.0.2" version = "2.0.3"
description = "Access an HTTP client written in Rust." description = "Access an HTTP client written in Rust."
edition = { workspace = true } edition = { workspace = true }
authors = { workspace = true } authors = { workspace = true }
@@ -34,7 +34,7 @@ serde_json = { workspace = true }
tauri = { workspace = true } tauri = { workspace = true }
thiserror = { workspace = true } thiserror = { workspace = true }
tokio = { version = "1", features = ["sync", "macros"] } tokio = { version = "1", features = ["sync", "macros"] }
tauri-plugin-fs = { path = "../fs", version = "2.0.2" } tauri-plugin-fs = { path = "../fs", version = "2.0.3" }
urlpattern = "0.3" urlpattern = "0.3"
regex = "1" regex = "1"
http = "1" http = "1"
+6
View File
@@ -1,5 +1,11 @@
# Changelog # Changelog
## \[2.0.3]
### Dependencies
- Upgraded to `fs@2.0.3`
## \[2.0.2] ## \[2.0.2]
### Dependencies ### Dependencies
+2 -2
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "tauri-plugin-persisted-scope" name = "tauri-plugin-persisted-scope"
version = "2.0.2" version = "2.0.3"
description = "Save filesystem and asset scopes and restore them when the app is reopened." description = "Save filesystem and asset scopes and restore them when the app is reopened."
authors = { workspace = true } authors = { workspace = true }
license = { workspace = true } license = { workspace = true }
@@ -27,7 +27,7 @@ log = { workspace = true }
thiserror = { workspace = true } thiserror = { workspace = true }
aho-corasick = "1" aho-corasick = "1"
bincode = "1" bincode = "1"
tauri-plugin-fs = { path = "../fs", version = "2.0.2" } tauri-plugin-fs = { path = "../fs", version = "2.0.3" }
[features] [features]
protocol-asset = ["tauri/protocol-asset"] protocol-asset = ["tauri/protocol-asset"]
+11
View File
@@ -37,6 +37,17 @@ regex = "1"
open = { version = "5", features = ["shellexecute-on-windows"] } open = { version = "5", features = ["shellexecute-on-windows"] }
encoding_rs = "0.8" encoding_rs = "0.8"
os_pipe = "1" os_pipe = "1"
dunce = { workspace = true }
[target."cfg(windows)".dependencies.windows]
version = "0.54"
features = [
"Win32_Foundation",
"Win32_UI_Shell_Common",
"Win32_UI_WindowsAndMessaging",
"Win32_System_Com",
"Win32_System_Registry",
]
[target.'cfg(target_os = "ios")'.dependencies] [target.'cfg(target_os = "ios")'.dependencies]
tauri = { workspace = true, features = ["wry"] } tauri = { workspace = true, features = ["wry"] }
+9
View File
@@ -30,6 +30,15 @@ pub enum Error {
/// JSON error. /// JSON error.
#[error(transparent)] #[error(transparent)]
Json(#[from] serde_json::Error), Json(#[from] serde_json::Error),
/// API not supported on the current platform
#[error("API not supported on the current platform")]
UnsupportedPlatform,
#[error(transparent)]
#[cfg(windows)]
Win32Error(#[from] windows::core::Error),
/// Path doesn't have a parent.
#[error("Path doesn't have a parent: {0}")]
NoParent(PathBuf),
/// Utf8 error. /// Utf8 error.
#[error(transparent)] #[error(transparent)]
Utf8(#[from] std::string::FromUtf8Error), Utf8(#[from] std::string::FromUtf8Error),
+4
View File
@@ -85,6 +85,10 @@ impl<R: Runtime> Shell<R> {
.run_mobile_plugin("open", path.into()) .run_mobile_plugin("open", path.into())
.map_err(Into::into) .map_err(Into::into)
} }
pub fn show_item_in_directory<P: AsRef<Path>>(&self, p: P) -> Result<()> {
open::show_item_in_directory(p)
}
} }
pub trait ShellExt<R: Runtime> { pub trait ShellExt<R: Runtime> {
+3
View File
@@ -0,0 +1,3 @@
use std::path::Path;
pub fn show_item_in_directory(file: &Path) -> crate::Result<()> {}
@@ -9,6 +9,22 @@ use serde::{Deserialize, Deserializer};
use crate::scope::OpenScope; use crate::scope::OpenScope;
use std::str::FromStr; use std::str::FromStr;
#[cfg(windows)]
#[path = "windows.rs"]
mod platform;
#[cfg(target_os = "macos")]
#[path = "macos.rs"]
mod platform;
#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
))]
#[path = "linux.rs"]
mod platform;
/// Program to use on the [`open()`] call. /// Program to use on the [`open()`] call.
pub enum Program { pub enum Program {
/// Use the `open` program. /// Use the `open` program.
@@ -120,3 +136,30 @@ impl Program {
pub fn open<P: AsRef<str>>(scope: &OpenScope, path: P, with: Option<Program>) -> crate::Result<()> { pub fn open<P: AsRef<str>>(scope: &OpenScope, path: P, with: Option<Program>) -> crate::Result<()> {
scope.open(path.as_ref(), with).map_err(Into::into) scope.open(path.as_ref(), with).map_err(Into::into)
} }
pub fn show_item_in_directory<P: AsRef<std::path::Path>>(p: P) -> crate::Result<()> {
let p = p.as_ref().canonicalize()?;
let p = dunce::simplified(&p);
#[cfg(any(
windows,
target_os = "macos",
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
))]
return platform::show_item_in_directory(p);
#[cfg(not(any(
windows,
target_os = "macos",
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
)))]
Err(crate::Error::UnsupportedPlatform)
}
+59
View File
@@ -0,0 +1,59 @@
use std::path::Path;
use windows::{
core::{w, HSTRING, PCWSTR},
Win32::{
Foundation::ERROR_FILE_NOT_FOUND,
System::Com::CoInitialize,
UI::{
Shell::{
ILCreateFromPathW, ILFree, SHOpenFolderAndSelectItems, ShellExecuteExW,
SHELLEXECUTEINFOW,
},
WindowsAndMessaging::SW_SHOWNORMAL,
},
},
};
pub fn show_item_in_directory(file: &Path) -> crate::Result<()> {
let _ = unsafe { CoInitialize(None) };
let dir = file
.parent()
.ok_or_else(|| crate::Error::NoParent(file.to_path_buf()))?;
let dir = HSTRING::from(dir);
let dir_item = unsafe { ILCreateFromPathW(PCWSTR::from_raw(dir.as_ptr())) };
let file_h = HSTRING::from(file);
let file_item = unsafe { ILCreateFromPathW(PCWSTR::from_raw(file_h.as_ptr())) };
unsafe {
if let Err(e) = SHOpenFolderAndSelectItems(dir_item, Some(&[file_item]), 0) {
if e.code().0 == ERROR_FILE_NOT_FOUND.0 as i32 {
let is_dir = std::fs::metadata(file).map(|f| f.is_dir()).unwrap_or(false);
let mut info = SHELLEXECUTEINFOW {
cbSize: std::mem::size_of::<SHELLEXECUTEINFOW>() as _,
nShow: SW_SHOWNORMAL.0,
lpVerb: if is_dir {
w!("explore")
} else {
PCWSTR::null()
},
lpClass: if is_dir { w!("folder") } else { PCWSTR::null() },
lpFile: PCWSTR(file_h.as_ptr()),
..std::mem::zeroed()
};
ShellExecuteExW(&mut info)?;
}
}
}
unsafe {
ILFree(Some(dir_item));
ILFree(Some(file_item));
}
Ok(())
}
+7 -9
View File
@@ -23,7 +23,7 @@ pub(crate) async fn load<R: Runtime>(
pool.migrate(&migrator).await?; pool.migrate(&migrator).await?;
} }
db_instances.0.lock().await.insert(db.clone(), pool); db_instances.0.write().await.insert(db.clone(), pool);
Ok(db) Ok(db)
} }
@@ -36,7 +36,7 @@ pub(crate) async fn close(
db_instances: State<'_, DbInstances>, db_instances: State<'_, DbInstances>,
db: Option<String>, db: Option<String>,
) -> Result<bool, crate::Error> { ) -> Result<bool, crate::Error> {
let mut instances = db_instances.0.lock().await; let instances = db_instances.0.read().await;
let pools = if let Some(db) = db { let pools = if let Some(db) = db {
vec![db] vec![db]
@@ -45,9 +45,7 @@ pub(crate) async fn close(
}; };
for pool in pools { for pool in pools {
let db = instances let db = instances.get(&pool).ok_or(Error::DatabaseNotLoaded(pool))?;
.get_mut(&pool)
.ok_or(Error::DatabaseNotLoaded(pool))?;
db.close().await; db.close().await;
} }
@@ -62,9 +60,9 @@ pub(crate) async fn execute(
query: String, query: String,
values: Vec<JsonValue>, values: Vec<JsonValue>,
) -> Result<(u64, LastInsertId), crate::Error> { ) -> Result<(u64, LastInsertId), crate::Error> {
let mut instances = db_instances.0.lock().await; let instances = db_instances.0.read().await;
let db = instances.get_mut(&db).ok_or(Error::DatabaseNotLoaded(db))?; let db = instances.get(&db).ok_or(Error::DatabaseNotLoaded(db))?;
db.execute(query, values).await db.execute(query, values).await
} }
@@ -75,8 +73,8 @@ pub(crate) async fn select(
query: String, query: String,
values: Vec<JsonValue>, values: Vec<JsonValue>,
) -> Result<Vec<IndexMap<String, JsonValue>>, crate::Error> { ) -> Result<Vec<IndexMap<String, JsonValue>>, crate::Error> {
let mut instances = db_instances.0.lock().await; let instances = db_instances.0.read().await;
let db = instances.get_mut(&db).ok_or(Error::DatabaseNotLoaded(db))?; let db = instances.get(&db).ok_or(Error::DatabaseNotLoaded(db))?;
db.select(query, values).await db.select(query, values).await
} }
+4 -4
View File
@@ -29,12 +29,12 @@ use tauri::{
plugin::{Builder as PluginBuilder, TauriPlugin}, plugin::{Builder as PluginBuilder, TauriPlugin},
Manager, RunEvent, Runtime, Manager, RunEvent, Runtime,
}; };
use tokio::sync::Mutex; use tokio::sync::{Mutex, RwLock};
use std::collections::HashMap; use std::collections::HashMap;
#[derive(Default)] #[derive(Default)]
pub struct DbInstances(pub Mutex<HashMap<String, DbPool>>); pub struct DbInstances(pub RwLock<HashMap<String, DbPool>>);
#[derive(Serialize)] #[derive(Serialize)]
#[serde(untagged)] #[serde(untagged)]
@@ -140,7 +140,7 @@ impl Builder {
tauri::async_runtime::block_on(async move { tauri::async_runtime::block_on(async move {
let instances = DbInstances::default(); let instances = DbInstances::default();
let mut lock = instances.0.lock().await; let mut lock = instances.0.write().await;
for db in config.preload { for db in config.preload {
let pool = DbPool::connect(&db, app).await?; let pool = DbPool::connect(&db, app).await?;
@@ -168,7 +168,7 @@ impl Builder {
if let RunEvent::Exit = event { if let RunEvent::Exit = event {
tauri::async_runtime::block_on(async move { tauri::async_runtime::block_on(async move {
let instances = &*app.state::<DbInstances>(); let instances = &*app.state::<DbInstances>();
let instances = instances.0.lock().await; let instances = instances.0.read().await;
for value in instances.values() { for value in instances.values() {
value.close().await; value.close().await;
} }