Explorar el Código

fix(core/updater): read and parse response after checking status code, closes #6192 (#6575)

Amr Bashir hace 2 años
padre
commit
eb1ec0416c
Se han modificado 2 ficheros con 9 adiciones y 6 borrados
  1. 5 0
      .changes/core-updater-204.md
  2. 4 6
      core/tauri/src/updater/core.rs

+ 5 - 0
.changes/core-updater-204.md

@@ -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.

+ 4 - 6
core/tauri/src/updater/core.rs

@@ -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