Skip to content

Commit 0bc5d58

Browse files
fix(updater): download reuses check's timeout (#2572)
* fix(updater): download inherit timeout from check * Add change file
1 parent 517a29a commit 0bc5d58

File tree

6 files changed

+20
-13
lines changed

6 files changed

+20
-13
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"updater": "patch:bug"
3+
"updater-js": "patch:bug"
4+
---
5+
6+
Fix `timeout` passed to `check` gets re-used by `download` and `downloadAndinstall`

plugins/updater/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Afterwards all the plugin's APIs are available through the JavaScript guest bind
7676
import { check } from '@tauri-apps/plugin-updater'
7777
import { relaunch } from '@tauri-apps/plugin-process'
7878
const update = await check()
79-
if (update?.available) {
79+
if (update) {
8080
await update.downloadAndInstall()
8181
await relaunch()
8282
}

plugins/updater/guest-js/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ async function check(options?: CheckOptions): Promise<Update | null> {
133133

134134
return await invoke<UpdateMetadata>('plugin:updater|check', {
135135
...options
136-
}).then((meta) => (meta.available ? new Update(meta) : null))
136+
}).then((meta) =>
137+
// TODO: Handle this in the rust side
138+
meta.available ? new Update(meta) : null
139+
)
137140
}
138141

139142
export type { CheckOptions, DownloadOptions, DownloadEvent }

plugins/updater/src/commands.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ pub(crate) struct Metadata {
4040
struct DownloadedBytes(pub Vec<u8>);
4141
impl Resource for DownloadedBytes {}
4242

43+
// TODO: Align this with the result of `updater.check` to Result<Option<Metadata>>
44+
// and remove `available` instead of handling this in the js side
4345
#[tauri::command]
4446
pub(crate) async fn check<R: Runtime>(
4547
webview: Webview<R>,

plugins/updater/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ impl Builder {
153153
I: IntoIterator<Item = S>,
154154
S: Into<OsString>,
155155
{
156-
let args = args.into_iter().map(|a| a.into()).collect::<Vec<_>>();
157-
self.installer_args.extend_from_slice(&args);
156+
self.installer_args.extend(args.into_iter().map(Into::into));
158157
self
159158
}
160159

@@ -214,7 +213,7 @@ impl Builder {
214213
config.pubkey = pubkey;
215214
}
216215
if let Some(windows) = &mut config.windows {
217-
windows.installer_args.extend_from_slice(&installer_args);
216+
windows.installer_args.extend(installer_args);
218217
}
219218
app.manage(UpdaterState {
220219
target,

plugins/updater/src/updater.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ pub struct UpdaterBuilder {
124124
impl UpdaterBuilder {
125125
pub(crate) fn new<R: Runtime>(app: &AppHandle<R>, config: crate::Config) -> Self {
126126
let app_ = app.clone();
127-
let run_on_main_thread =
128-
move |f: Box<dyn FnOnce() + Send + Sync + 'static>| app_.run_on_main_thread(f);
127+
let run_on_main_thread = move |f| app_.run_on_main_thread(f);
129128
Self {
130129
run_on_main_thread: Box::new(run_on_main_thread),
131130
installer_args: config
@@ -230,8 +229,7 @@ impl UpdaterBuilder {
230229
I: IntoIterator<Item = S>,
231230
S: Into<OsString>,
232231
{
233-
let args = args.into_iter().map(|a| a.into()).collect::<Vec<_>>();
234-
self.installer_args.extend_from_slice(&args);
232+
self.installer_args.extend(args.into_iter().map(Into::into));
235233
self
236234
}
237235

@@ -312,8 +310,7 @@ impl UpdaterBuilder {
312310
I: IntoIterator<Item = S>,
313311
S: Into<OsString>,
314312
{
315-
let args = args.into_iter().map(|a| a.into()).collect::<Vec<_>>();
316-
self.current_exe_args.extend_from_slice(&args);
313+
self.installer_args.extend(args.into_iter().map(Into::into));
317314
self
318315
}
319316
}
@@ -478,10 +475,10 @@ impl Updater {
478475
version: release.version.to_string(),
479476
date: release.pub_date,
480477
download_url: release.download_url(&self.json_target)?.to_owned(),
481-
body: release.notes.clone(),
482478
signature: release.signature(&self.json_target)?.to_owned(),
479+
body: release.notes,
483480
raw_json: raw_json.unwrap(),
484-
timeout: self.timeout,
481+
timeout: None,
485482
proxy: self.proxy.clone(),
486483
headers: self.headers.clone(),
487484
installer_args: self.installer_args.clone(),

0 commit comments

Comments
 (0)