Skip to content

Commit 3700793

Browse files
authored
fix(updater): emit UPTODATE when server responds with 204, closes #6934 (#6970)
1 parent 21d5eb8 commit 3700793

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tauri': 'patch'
3+
---
4+
5+
Emit `UPTODATE` update status to javascript when the updater server returns status code `204`

core/tauri/src/updater/mod.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,14 @@ impl<R: Runtime> UpdateBuilder<R> {
298298
/// Ok(())
299299
/// });
300300
/// ```
301+
///
302+
/// If ther server responds with status code `204`, this method will return [`Error::UpToDate`]
301303
pub async fn check(self) -> Result<UpdateResponse<R>> {
302304
let handle = self.inner.app.clone();
303-
let events = self.events;
304305
// check updates
305306
match self.inner.build().await {
306307
Ok(update) => {
307-
if events {
308+
if self.events {
308309
// send notification if we need to update
309310
if update.should_update {
310311
let body = update.body.clone().unwrap_or_else(|| String::from(""));
@@ -341,7 +342,13 @@ impl<R: Runtime> UpdateBuilder<R> {
341342
}
342343
Err(e) => {
343344
if self.events {
344-
send_status_update(&handle, UpdaterEvent::Error(e.to_string()));
345+
send_status_update(
346+
&handle,
347+
match e {
348+
Error::UpToDate => UpdaterEvent::AlreadyUpToDate,
349+
_ => UpdaterEvent::Error(e.to_string()),
350+
},
351+
);
345352
}
346353
Err(e)
347354
}
@@ -428,7 +435,13 @@ pub(crate) async fn check_update_with_dialog<R: Runtime>(handle: AppHandle<R>) {
428435
}
429436
}
430437
Err(e) => {
431-
send_status_update(&handle, UpdaterEvent::Error(e.to_string()));
438+
send_status_update(
439+
&handle,
440+
match e {
441+
Error::UpToDate => UpdaterEvent::AlreadyUpToDate,
442+
_ => UpdaterEvent::Error(e.to_string()),
443+
},
444+
);
432445
}
433446
}
434447
}

0 commit comments

Comments
 (0)