mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-06-12 14:17:48 +02:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d8efd3cd20 | |||
| 5d39ddcf22 | |||
| 2050a3bea2 | |||
| c078f57a09 | |||
| dc5721ac13 | |||
| 1d9741b52b | |||
| 7a37355e17 |
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"window-state": patch
|
||||
---
|
||||
|
||||
Fix deadlock when trying to restore window states on initial load
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"upload": 'patch:bug'
|
||||
---
|
||||
|
||||
fix download content to file when unsuccessful response
|
||||
@@ -22,6 +22,8 @@
|
||||
".changes/fix-linux-updater-permission-error.md",
|
||||
".changes/fix-restore-minimized-window-position.md",
|
||||
".changes/fix-restore-minimized-window-state.md",
|
||||
".changes/fix-restore-window-state-deadlock.md",
|
||||
".changes/fix-upload-handle-non-success-download.md",
|
||||
".changes/fs-dialog-file-path-methods.md",
|
||||
".changes/fs-dialog-file-path-traits.md",
|
||||
".changes/fs-dialog-non-exhaustive-error.md",
|
||||
|
||||
Generated
+100
-45
@@ -206,9 +206,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.87"
|
||||
version = "1.0.89"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8"
|
||||
checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6"
|
||||
|
||||
[[package]]
|
||||
name = "api"
|
||||
@@ -286,9 +286,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "arboard"
|
||||
version = "3.4.0"
|
||||
version = "3.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fb4009533e8ff8f1450a5bcbc30f4242a1d34442221f72314bea1f5dc9c7f89"
|
||||
checksum = "df099ccb16cd014ff054ac1bf392c67feeef57164b05c42f037cd40f5d4357f4"
|
||||
dependencies = [
|
||||
"clipboard-win",
|
||||
"core-graphics 0.23.2",
|
||||
@@ -304,9 +304,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
version = "0.3.8"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a"
|
||||
checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
@@ -337,6 +337,16 @@ dependencies = [
|
||||
"zbus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "assert-json-diff"
|
||||
version = "2.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-broadcast"
|
||||
version = "0.7.1"
|
||||
@@ -431,9 +441,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "async-process"
|
||||
version = "2.2.4"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8a07789659a4d385b79b18b9127fc27e1a59e1e89117c78c5ea3b806f016374"
|
||||
checksum = "63255f1dc2381611000436537bbedfe83183faa303a5a0edaf191edef06526bb"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-io",
|
||||
@@ -446,7 +456,6 @@ dependencies = [
|
||||
"futures-lite",
|
||||
"rustix",
|
||||
"tracing",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -883,9 +892,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.1.18"
|
||||
version = "1.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476"
|
||||
checksum = "2d74707dde2ba56f86ae90effb3b43ddd369504387e718014de010cec7959800"
|
||||
dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
@@ -1088,6 +1097,16 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "colored"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "combine"
|
||||
version = "4.6.7"
|
||||
@@ -1888,9 +1907,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "error-code"
|
||||
version = "3.2.0"
|
||||
version = "3.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0474425d51df81997e2f90a21591180b38eccf27292d755f3e30750225c175b"
|
||||
checksum = "a5d9305ccc6942a704f4335694ecd3de2ea531b114ac2d51f5f843750787a92f"
|
||||
|
||||
[[package]]
|
||||
name = "etcetera"
|
||||
@@ -1961,7 +1980,7 @@ version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9f0c14694cbd524c8720dd69b0e3179344f04ebb5f90f2e4a440c6ea3b2f1ee"
|
||||
dependencies = [
|
||||
"colored",
|
||||
"colored 1.9.4",
|
||||
"log",
|
||||
]
|
||||
|
||||
@@ -2526,9 +2545,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||
|
||||
[[package]]
|
||||
name = "global-hotkey"
|
||||
version = "0.6.1"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4b86f7342b0e2abcf5e50ed8afd8bb9ffb6e30619d90f1e1a774b934a61f3e9"
|
||||
checksum = "d1b75248f33c73df1ed69673f6cb36d2e048ae84d29aa1d3e53199d138ebb1df"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"keyboard-types",
|
||||
@@ -2808,6 +2827,7 @@ dependencies = [
|
||||
"http",
|
||||
"http-body",
|
||||
"httparse",
|
||||
"httpdate",
|
||||
"itoa 1.0.11",
|
||||
"pin-project-lite",
|
||||
"smallvec",
|
||||
@@ -2852,9 +2872,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hyper-util"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9"
|
||||
checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
@@ -3463,9 +3483,9 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
|
||||
|
||||
[[package]]
|
||||
name = "mac-notification-sys"
|
||||
version = "0.6.1"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51fca4d74ff9dbaac16a01b924bc3693fa2bba0862c2c633abc73f9a8ea21f64"
|
||||
checksum = "dce8f34f3717aa37177e723df6c1fc5fb02b2a1087374ea3fe0ea42316dc8f91"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"dirs-next",
|
||||
@@ -3623,6 +3643,30 @@ dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mockito"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09b34bd91b9e5c5b06338d392463e1318d683cf82ec3d3af4014609be6e2108d"
|
||||
dependencies = [
|
||||
"assert-json-diff",
|
||||
"bytes",
|
||||
"colored 2.1.0",
|
||||
"futures-util",
|
||||
"http",
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"hyper",
|
||||
"hyper-util",
|
||||
"log",
|
||||
"rand 0.8.5",
|
||||
"regex",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"similar",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "muda"
|
||||
version = "0.14.1"
|
||||
@@ -3771,9 +3815,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "notify-rust"
|
||||
version = "4.11.1"
|
||||
version = "4.11.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26a1d03b6305ecefdd9c6c60150179bb8d9f0cd4e64bbcad1e41419e7bf5e414"
|
||||
checksum = "5134a72dc570b178bff81b01e81ab14a6fcc015391ed4b3b14853090658cd3a3"
|
||||
dependencies = [
|
||||
"log",
|
||||
"mac-notification-sys",
|
||||
@@ -4014,9 +4058,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.19.0"
|
||||
version = "1.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
||||
checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe"
|
||||
|
||||
[[package]]
|
||||
name = "opaque-debug"
|
||||
@@ -4833,9 +4877,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.3"
|
||||
version = "0.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4"
|
||||
checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
]
|
||||
@@ -5138,9 +5182,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.36"
|
||||
version = "0.38.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f55e80d50763938498dd5ebb18647174e0c76dc38c5505294bb224624f30f36"
|
||||
checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"errno",
|
||||
@@ -5151,9 +5195,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.23.12"
|
||||
version = "0.23.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044"
|
||||
checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"ring",
|
||||
@@ -5207,9 +5251,9 @@ checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0"
|
||||
|
||||
[[package]]
|
||||
name = "rustls-webpki"
|
||||
version = "0.102.7"
|
||||
version = "0.102.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84678086bd54edf2b415183ed7a94d0efb049f1b646a33e22a36f3794be6ae56"
|
||||
checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"rustls-pki-types",
|
||||
@@ -5614,6 +5658,12 @@ version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a"
|
||||
|
||||
[[package]]
|
||||
name = "similar"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e"
|
||||
|
||||
[[package]]
|
||||
name = "single-instance-example"
|
||||
version = "0.1.0"
|
||||
@@ -6261,13 +6311,12 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
|
||||
|
||||
[[package]]
|
||||
name = "tauri"
|
||||
version = "2.0.0-rc.12"
|
||||
version = "2.0.0-rc.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65e5d4a319f11ae72c77d0f4dbd9703ab6b401eb91d1ca88d89c33d13d4ea20c"
|
||||
checksum = "0a283cb3d25e46e2f5d99f0068928dadaca4a19558c555f91a5064e3299c691d"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
"cocoa",
|
||||
"dirs 5.0.1",
|
||||
"dunce",
|
||||
"embed_plist",
|
||||
@@ -6284,7 +6333,9 @@ dependencies = [
|
||||
"log",
|
||||
"mime",
|
||||
"muda",
|
||||
"objc",
|
||||
"objc2",
|
||||
"objc2-app-kit",
|
||||
"objc2-foundation",
|
||||
"percent-encoding",
|
||||
"plist",
|
||||
"raw-window-handle",
|
||||
@@ -6807,10 +6858,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-upload"
|
||||
version = "2.0.0-rc.1"
|
||||
version = "2.0.0-rc.2"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"log",
|
||||
"mockito",
|
||||
"read-progress-stream",
|
||||
"reqwest",
|
||||
"serde",
|
||||
@@ -6841,7 +6893,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-window-state"
|
||||
version = "2.0.0-rc.4"
|
||||
version = "2.0.0-rc.5"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"log",
|
||||
@@ -6873,15 +6925,17 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tauri-runtime-wry"
|
||||
version = "2.0.0-rc.11"
|
||||
version = "2.0.0-rc.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "466c418aef2ddc7d31173a5b00bfae3df9b58ed66644339f3ca55008bfc54f25"
|
||||
checksum = "e17625b7cf63958d53945e199391d11c9f195fb3d1cb8aeb64dc3084d0091b92"
|
||||
dependencies = [
|
||||
"cocoa",
|
||||
"gtk",
|
||||
"http",
|
||||
"jni",
|
||||
"log",
|
||||
"objc2",
|
||||
"objc2-app-kit",
|
||||
"objc2-foundation",
|
||||
"percent-encoding",
|
||||
"raw-window-handle",
|
||||
"softbuffer",
|
||||
@@ -7113,6 +7167,7 @@ dependencies = [
|
||||
"bytes",
|
||||
"libc",
|
||||
"mio 1.0.2",
|
||||
"parking_lot",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
@@ -7491,9 +7546,9 @@ checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
@@ -7512,9 +7567,9 @@ checksum = "52ea75f83c0137a9b98608359a5f1af8144876eb67bcb1ce837368e906a9f524"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.11.0"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
|
||||
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
|
||||
|
||||
[[package]]
|
||||
name = "unicode_categories"
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## \[2.0.0-rc.2]
|
||||
|
||||
### bug
|
||||
|
||||
- [`1d9741b5`](https://github.com/tauri-apps/plugins-workspace/commit/1d9741b52bb242d32b2ffd46fb4343a501cbd54b) ([#1783](https://github.com/tauri-apps/plugins-workspace/pull/1783) by [@fxsalazar](https://github.com/tauri-apps/plugins-workspace/../../fxsalazar)) fix download content to file when unsuccessful response
|
||||
|
||||
## \[2.0.0-rc.1]
|
||||
|
||||
- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tauri-plugin-upload"
|
||||
version = "2.0.0-rc.1"
|
||||
version = "2.0.0-rc.2"
|
||||
description = "Upload files from disk to a remote server over HTTP."
|
||||
authors = { workspace = true }
|
||||
license = { workspace = true }
|
||||
@@ -35,3 +35,7 @@ read-progress-stream = "1.0.0"
|
||||
native-tls = ["reqwest/native-tls"]
|
||||
native-tls-vendored = ["reqwest/native-tls-vendored"]
|
||||
rustls-tls = ["reqwest/rustls-tls"]
|
||||
|
||||
[dev-dependencies]
|
||||
mockito = "1.5.0"
|
||||
tokio = { version = "1", features = ["macros"] }
|
||||
|
||||
@@ -70,13 +70,19 @@ async fn download(
|
||||
let client = reqwest::Client::new();
|
||||
|
||||
let mut request = client.get(url);
|
||||
// Loop trought the headers keys and values
|
||||
// Loop through the headers keys and values
|
||||
// and add them to the request object.
|
||||
for (key, value) in headers {
|
||||
request = request.header(&key, value);
|
||||
}
|
||||
|
||||
let response = request.send().await?;
|
||||
if !response.status().is_success() {
|
||||
return Err(Error::HttpErrorCode(
|
||||
response.status().as_u16(),
|
||||
response.text().await.unwrap_or_default(),
|
||||
));
|
||||
}
|
||||
let total = response.content_length().unwrap_or(0);
|
||||
|
||||
let mut file = BufWriter::new(File::create(file_path).await?);
|
||||
@@ -112,7 +118,7 @@ async fn upload(
|
||||
.header(reqwest::header::CONTENT_LENGTH, file_len)
|
||||
.body(file_to_body(on_progress, file));
|
||||
|
||||
// Loop trought the headers keys and values
|
||||
// Loop through the headers keys and values
|
||||
// and add them to the request object.
|
||||
for (key, value) in headers {
|
||||
request = request.header(&key, value);
|
||||
@@ -145,3 +151,64 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
.invoke_handler(tauri::generate_handler![download, upload])
|
||||
.build()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use mockito::{self, Mock, Server, ServerGuard};
|
||||
use tauri::ipc::InvokeResponseBody;
|
||||
struct MockedServer {
|
||||
_server: ServerGuard,
|
||||
url: String,
|
||||
mocked_endpoint: Mock,
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn should_error_if_status_not_success() {
|
||||
let mocked_server = spawn_server_mocked(400).await;
|
||||
let result = download_file(&mocked_server.url).await;
|
||||
mocked_server.mocked_endpoint.assert();
|
||||
assert!(result.is_err());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn should_download_file_successfully() {
|
||||
let mocked_server = spawn_server_mocked(200).await;
|
||||
let result = download_file(&mocked_server.url).await;
|
||||
mocked_server.mocked_endpoint.assert();
|
||||
assert!(
|
||||
result.is_ok(),
|
||||
"failed to download file: {}",
|
||||
result.unwrap_err()
|
||||
);
|
||||
}
|
||||
|
||||
async fn download_file(url: &str) -> Result<()> {
|
||||
let file_path = concat!(env!("CARGO_MANIFEST_DIR"), "/test/test.txt");
|
||||
let headers = HashMap::new();
|
||||
let sender: Channel<ProgressPayload> =
|
||||
Channel::new(|msg: InvokeResponseBody| -> tauri::Result<()> {
|
||||
let _ = msg;
|
||||
Ok(())
|
||||
});
|
||||
download(url, file_path, headers, sender).await
|
||||
}
|
||||
|
||||
async fn spawn_server_mocked(return_status: usize) -> MockedServer {
|
||||
let mut _server = Server::new_async().await;
|
||||
let path = "/mock_test";
|
||||
let mock = _server
|
||||
.mock("GET", path)
|
||||
.with_status(return_status)
|
||||
.with_body("mocked response body")
|
||||
.create_async()
|
||||
.await;
|
||||
|
||||
let url = _server.url() + path;
|
||||
MockedServer {
|
||||
_server,
|
||||
url,
|
||||
mocked_endpoint: mock,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
mocked response body
|
||||
@@ -1,5 +1,9 @@
|
||||
# Changelog
|
||||
|
||||
## \[2.0.0-rc.5]
|
||||
|
||||
- [`7a37355e`](https://github.com/tauri-apps/plugins-workspace/commit/7a37355e177772cbddf24397d5a23280e00558af) ([#1787](https://github.com/tauri-apps/plugins-workspace/pull/1787) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Fix deadlock when trying to restore window states on initial load
|
||||
|
||||
## \[2.0.0-rc.4]
|
||||
|
||||
- [`204e5aac`](https://github.com/tauri-apps/plugins-workspace/commit/204e5aacad7e8f99a9a08f4a45cfed83643c1cc0) ([#1743](https://github.com/tauri-apps/plugins-workspace/pull/1743)) Fix can't restore a minimized window's size and position properly
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tauri-plugin-window-state"
|
||||
version = "2.0.0-rc.4"
|
||||
version = "2.0.0-rc.5"
|
||||
description = "Save window positions and sizes and restore them when the app is reopened."
|
||||
authors = { workspace = true }
|
||||
license = { workspace = true }
|
||||
|
||||
@@ -105,6 +105,8 @@ impl Default for WindowState {
|
||||
}
|
||||
|
||||
struct WindowStateCache(Arc<Mutex<HashMap<String, WindowState>>>);
|
||||
/// Used to prevent deadlocks from resize and position event listeners setting the cached state on restoring states
|
||||
struct RestoringWindowState(Mutex<()>);
|
||||
pub trait AppHandleExt {
|
||||
/// Saves all open windows state to disk
|
||||
fn save_window_state(&self, flags: StateFlags) -> Result<()>;
|
||||
@@ -167,6 +169,8 @@ impl<R: Runtime> WindowExt for Window<R> {
|
||||
.map(|map| map(self.label()))
|
||||
.unwrap_or_else(|| self.label());
|
||||
|
||||
let restoring_window_state = self.state::<RestoringWindowState>();
|
||||
let _restoring_window_lock = restoring_window_state.0.lock().unwrap();
|
||||
let cache = self.state::<WindowStateCache>();
|
||||
let mut c = cache.0.lock().unwrap();
|
||||
|
||||
@@ -396,6 +400,7 @@ impl Builder {
|
||||
Default::default()
|
||||
};
|
||||
app.manage(WindowStateCache(cache));
|
||||
app.manage(RestoringWindowState(Mutex::new(())));
|
||||
app.manage(PluginState {
|
||||
filename,
|
||||
map_label,
|
||||
@@ -443,7 +448,13 @@ impl Builder {
|
||||
}
|
||||
|
||||
WindowEvent::Moved(position) if flags.contains(StateFlags::POSITION) => {
|
||||
if !window_clone.is_minimized().unwrap_or_default() {
|
||||
if window_clone
|
||||
.state::<RestoringWindowState>()
|
||||
.0
|
||||
.try_lock()
|
||||
.is_ok()
|
||||
&& !window_clone.is_minimized().unwrap_or_default()
|
||||
{
|
||||
let mut c = cache.lock().unwrap();
|
||||
if let Some(state) = c.get_mut(&label) {
|
||||
state.prev_x = state.x;
|
||||
@@ -455,7 +466,12 @@ impl Builder {
|
||||
}
|
||||
}
|
||||
WindowEvent::Resized(size) if flags.contains(StateFlags::SIZE) => {
|
||||
if !window_clone.is_minimized().unwrap_or_default()
|
||||
if window_clone
|
||||
.state::<RestoringWindowState>()
|
||||
.0
|
||||
.try_lock()
|
||||
.is_ok()
|
||||
&& !window_clone.is_minimized().unwrap_or_default()
|
||||
&& !window_clone.is_maximized().unwrap_or_default()
|
||||
{
|
||||
let mut c = cache.lock().unwrap();
|
||||
|
||||
Generated
+11
-13
@@ -2743,9 +2743,9 @@ snapshots:
|
||||
- encoding
|
||||
- mocha
|
||||
|
||||
'@covector/assemble@0.12.0(mocha@10.7.3)':
|
||||
'@covector/assemble@0.12.0':
|
||||
dependencies:
|
||||
'@covector/command': 0.8.0(mocha@10.7.3)
|
||||
'@covector/command': 0.8.0
|
||||
'@covector/files': 0.8.0
|
||||
effection: 2.0.8(mocha@10.7.3)
|
||||
js-yaml: 4.1.0
|
||||
@@ -2756,10 +2756,9 @@ snapshots:
|
||||
unified: 9.2.2
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- mocha
|
||||
- supports-color
|
||||
|
||||
'@covector/changelog@0.12.0(mocha@10.7.3)':
|
||||
'@covector/changelog@0.12.0':
|
||||
dependencies:
|
||||
'@covector/files': 0.8.0
|
||||
effection: 2.0.8(mocha@10.7.3)
|
||||
@@ -2769,16 +2768,14 @@ snapshots:
|
||||
unified: 9.2.2
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- mocha
|
||||
- supports-color
|
||||
|
||||
'@covector/command@0.8.0(mocha@10.7.3)':
|
||||
'@covector/command@0.8.0':
|
||||
dependencies:
|
||||
'@effection/process': 2.1.4(mocha@10.7.3)
|
||||
'@effection/process': 2.1.4
|
||||
effection: 2.0.8(mocha@10.7.3)
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- mocha
|
||||
|
||||
'@covector/files@0.8.0':
|
||||
dependencies:
|
||||
@@ -2825,8 +2822,10 @@ snapshots:
|
||||
dependencies:
|
||||
effection: 2.0.8(mocha@10.7.3)
|
||||
mocha: 10.7.3
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
|
||||
'@effection/process@2.1.4(mocha@10.7.3)':
|
||||
'@effection/process@2.1.4':
|
||||
dependencies:
|
||||
cross-spawn: 7.0.3
|
||||
ctrlc-windows: 2.1.0
|
||||
@@ -2834,7 +2833,6 @@ snapshots:
|
||||
shellwords: 0.1.1
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- mocha
|
||||
|
||||
'@effection/stream@2.0.6':
|
||||
dependencies:
|
||||
@@ -3680,9 +3678,9 @@ snapshots:
|
||||
dependencies:
|
||||
'@clack/prompts': 0.7.0
|
||||
'@covector/apply': 0.10.0(mocha@10.7.3)
|
||||
'@covector/assemble': 0.12.0(mocha@10.7.3)
|
||||
'@covector/changelog': 0.12.0(mocha@10.7.3)
|
||||
'@covector/command': 0.8.0(mocha@10.7.3)
|
||||
'@covector/assemble': 0.12.0
|
||||
'@covector/changelog': 0.12.0
|
||||
'@covector/command': 0.8.0
|
||||
'@covector/files': 0.8.0
|
||||
effection: 2.0.8(mocha@10.7.3)
|
||||
globby: 11.1.0
|
||||
|
||||
Reference in New Issue
Block a user