Skip to content

Commit

Permalink
fix(core/updater): read and parse response after checking status code,
Browse files Browse the repository at this point in the history
…closes #6192 (#6575)
  • Loading branch information
amrbashir authored Mar 31, 2023
1 parent 5e0c448 commit eb1ec04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changes/core-updater-204.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri': 'patch'
---

Fix `UpdaterBuilder::check` returning a parsing error when `204` is sent from server where it should instead return a `UpToDate` error.
10 changes: 4 additions & 6 deletions core/tauri/src/updater/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,18 +383,16 @@ impl<R: Runtime> UpdateBuilder<R> {
// If we got a success, we stop the loop
// and we set our remote_release variable
if let Ok(res) = resp {
let res = res.read().await?;
let status = res.status();
// got status code 2XX
if StatusCode::from_u16(res.status)
.map_err(|e| Error::Builder(e.to_string()))?
.is_success()
{
if status.is_success() {
// if we got 204
if StatusCode::NO_CONTENT.as_u16() == res.status {
if status == StatusCode::NO_CONTENT {
// return with `UpToDate` error
// we should catch on the client
return Err(Error::UpToDate);
};
let res = res.read().await?;
// Convert the remote result to our local struct
let built_release = serde_json::from_value(res.data).map_err(Into::into);
// make sure all went well and the remote data is compatible
Expand Down

0 comments on commit eb1ec04

Please sign in to comment.