Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/updater-download-inherit-check-timeout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"updater": "patch:bug"
"updater-js": "patch:bug"
---

Fix `timeout` passed to `check` gets re-used by `download` and `downloadAndinstall`
2 changes: 1 addition & 1 deletion plugins/updater/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Afterwards all the plugin's APIs are available through the JavaScript guest bind
import { check } from '@tauri-apps/plugin-updater'
import { relaunch } from '@tauri-apps/plugin-process'
const update = await check()
if (update?.available) {
if (update) {
await update.downloadAndInstall()
await relaunch()
}
Expand Down
5 changes: 4 additions & 1 deletion plugins/updater/guest-js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ async function check(options?: CheckOptions): Promise<Update | null> {

return await invoke<UpdateMetadata>('plugin:updater|check', {
...options
}).then((meta) => (meta.available ? new Update(meta) : null))
}).then((meta) =>
// TODO: Handle this in the rust side
meta.available ? new Update(meta) : null
)
}

export type { CheckOptions, DownloadOptions, DownloadEvent }
Expand Down
2 changes: 2 additions & 0 deletions plugins/updater/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub(crate) struct Metadata {
struct DownloadedBytes(pub Vec<u8>);
impl Resource for DownloadedBytes {}

// TODO: Align this with the result of `updater.check` to Result<Option<Metadata>>
// and remove `available` instead of handling this in the js side
Comment on lines +43 to +44
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it's considered breaking if we change this from returning Result<Metadata> to Result<Option<Metadata>>, if not then I would like to do it before v3

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can change it, if you want since we now require users to sync their rust and js versions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's nice, I'll do it later

#[tauri::command]
pub(crate) async fn check<R: Runtime>(
webview: Webview<R>,
Expand Down
5 changes: 2 additions & 3 deletions plugins/updater/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ impl Builder {
I: IntoIterator<Item = S>,
S: Into<OsString>,
{
let args = args.into_iter().map(|a| a.into()).collect::<Vec<_>>();
self.installer_args.extend_from_slice(&args);
self.installer_args.extend(args.into_iter().map(Into::into));
self
}

Expand Down Expand Up @@ -214,7 +213,7 @@ impl Builder {
config.pubkey = pubkey;
}
if let Some(windows) = &mut config.windows {
windows.installer_args.extend_from_slice(&installer_args);
windows.installer_args.extend(installer_args);
}
app.manage(UpdaterState {
target,
Expand Down
13 changes: 5 additions & 8 deletions plugins/updater/src/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ pub struct UpdaterBuilder {
impl UpdaterBuilder {
pub(crate) fn new<R: Runtime>(app: &AppHandle<R>, config: crate::Config) -> Self {
let app_ = app.clone();
let run_on_main_thread =
move |f: Box<dyn FnOnce() + Send + Sync + 'static>| app_.run_on_main_thread(f);
let run_on_main_thread = move |f| app_.run_on_main_thread(f);
Self {
run_on_main_thread: Box::new(run_on_main_thread),
installer_args: config
Expand Down Expand Up @@ -230,8 +229,7 @@ impl UpdaterBuilder {
I: IntoIterator<Item = S>,
S: Into<OsString>,
{
let args = args.into_iter().map(|a| a.into()).collect::<Vec<_>>();
self.installer_args.extend_from_slice(&args);
self.installer_args.extend(args.into_iter().map(Into::into));
self
}

Expand Down Expand Up @@ -312,8 +310,7 @@ impl UpdaterBuilder {
I: IntoIterator<Item = S>,
S: Into<OsString>,
{
let args = args.into_iter().map(|a| a.into()).collect::<Vec<_>>();
self.current_exe_args.extend_from_slice(&args);
self.installer_args.extend(args.into_iter().map(Into::into));
self
}
}
Expand Down Expand Up @@ -478,10 +475,10 @@ impl Updater {
version: release.version.to_string(),
date: release.pub_date,
download_url: release.download_url(&self.json_target)?.to_owned(),
body: release.notes.clone(),
signature: release.signature(&self.json_target)?.to_owned(),
body: release.notes,
raw_json: raw_json.unwrap(),
timeout: self.timeout,
timeout: None,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual change 🙃

proxy: self.proxy.clone(),
headers: self.headers.clone(),
installer_args: self.installer_args.clone(),
Expand Down
Loading