Skip to content

Commit eb1ec04

Browse files
authored
fix(core/updater): read and parse response after checking status code, closes #6192 (#6575)
1 parent 5e0c448 commit eb1ec04

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

.changes/core-updater-204.md

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+
Fix `UpdaterBuilder::check` returning a parsing error when `204` is sent from server where it should instead return a `UpToDate` error.

core/tauri/src/updater/core.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,18 +383,16 @@ impl<R: Runtime> UpdateBuilder<R> {
383383
// If we got a success, we stop the loop
384384
// and we set our remote_release variable
385385
if let Ok(res) = resp {
386-
let res = res.read().await?;
386+
let status = res.status();
387387
// got status code 2XX
388-
if StatusCode::from_u16(res.status)
389-
.map_err(|e| Error::Builder(e.to_string()))?
390-
.is_success()
391-
{
388+
if status.is_success() {
392389
// if we got 204
393-
if StatusCode::NO_CONTENT.as_u16() == res.status {
390+
if status == StatusCode::NO_CONTENT {
394391
// return with `UpToDate` error
395392
// we should catch on the client
396393
return Err(Error::UpToDate);
397394
};
395+
let res = res.read().await?;
398396
// Convert the remote result to our local struct
399397
let built_release = serde_json::from_value(res.data).map_err(Into::into);
400398
// make sure all went well and the remote data is compatible

0 commit comments

Comments
 (0)