mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-07-24 17:20:51 +02:00
feat(updater): Collect unknown response fields (#2325)
This commit is contained in:
@@ -34,6 +34,7 @@ pub(crate) struct Metadata {
|
||||
version: String,
|
||||
date: Option<String>,
|
||||
body: Option<String>,
|
||||
raw_json: serde_json::Value,
|
||||
}
|
||||
|
||||
struct DownloadedBytes(pub Vec<u8>);
|
||||
@@ -73,6 +74,7 @@ pub(crate) async fn check<R: Runtime>(
|
||||
metadata.version.clone_from(&update.version);
|
||||
metadata.date = update.date.map(|d| d.to_string());
|
||||
metadata.body.clone_from(&update.body);
|
||||
metadata.raw_json.clone_from(&update.raw_json);
|
||||
metadata.rid = Some(webview.resources_table().add(update));
|
||||
}
|
||||
|
||||
|
||||
@@ -330,6 +330,7 @@ impl Updater {
|
||||
}
|
||||
|
||||
let mut remote_release: Option<RemoteRelease> = None;
|
||||
let mut raw_json: Option<serde_json::Value> = None;
|
||||
let mut last_error: Option<Error> = None;
|
||||
for url in &self.endpoints {
|
||||
// replace {{current_version}}, {{target}} and {{arch}} in the provided URL
|
||||
@@ -379,7 +380,8 @@ impl Updater {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
match serde_json::from_value::<RemoteRelease>(res.json().await?)
|
||||
raw_json = Some(res.json().await?);
|
||||
match serde_json::from_value::<RemoteRelease>(raw_json.clone().unwrap())
|
||||
.map_err(Into::into)
|
||||
{
|
||||
Ok(release) => {
|
||||
@@ -421,6 +423,7 @@ impl Updater {
|
||||
download_url: release.download_url(&self.json_target)?.to_owned(),
|
||||
body: release.notes.clone(),
|
||||
signature: release.signature(&self.json_target)?.to_owned(),
|
||||
raw_json: raw_json.unwrap(),
|
||||
timeout: self.timeout,
|
||||
proxy: self.proxy.clone(),
|
||||
headers: self.headers.clone(),
|
||||
@@ -454,6 +457,8 @@ pub struct Update {
|
||||
pub download_url: Url,
|
||||
/// Signature announced
|
||||
pub signature: String,
|
||||
/// The raw version of server's JSON response. Useful if the response contains additional fields that the updater doesn't handle.
|
||||
pub raw_json: serde_json::Value,
|
||||
/// Request timeout
|
||||
pub timeout: Option<Duration>,
|
||||
/// Request proxy
|
||||
|
||||
Reference in New Issue
Block a user