mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-08-27 19:50:24 +02:00
feat(updater): inject bundle_type into endpoint url (#2960)
* feat(updater): inject bundle_type into endpoint url * Revert schemas * replace with unknown if none
This commit is contained in:
@@ -392,7 +392,7 @@ impl Updater {
|
|||||||
let mut raw_json: Option<serde_json::Value> = None;
|
let mut raw_json: Option<serde_json::Value> = None;
|
||||||
let mut last_error: Option<Error> = None;
|
let mut last_error: Option<Error> = None;
|
||||||
for url in &self.endpoints {
|
for url in &self.endpoints {
|
||||||
// replace {{current_version}}, {{target}} and {{arch}} in the provided URL
|
// replace {{current_version}}, {{target}}, {{arch}} and {{bundle_type}} in the provided URL
|
||||||
// this is useful if we need to query example
|
// this is useful if we need to query example
|
||||||
// https://releases.myapp.com/update/{{target}}/{{arch}}/{{current_version}}
|
// https://releases.myapp.com/update/{{target}}/{{arch}}/{{current_version}}
|
||||||
// will be translated into ->
|
// will be translated into ->
|
||||||
@@ -404,6 +404,9 @@ impl Updater {
|
|||||||
const CONTROLS_ADD: &AsciiSet = &CONTROLS.add(b'+');
|
const CONTROLS_ADD: &AsciiSet = &CONTROLS.add(b'+');
|
||||||
let encoded_version = percent_encoding::percent_encode(version, CONTROLS_ADD);
|
let encoded_version = percent_encoding::percent_encode(version, CONTROLS_ADD);
|
||||||
let encoded_version = encoded_version.to_string();
|
let encoded_version = encoded_version.to_string();
|
||||||
|
let installer = installer_for_bundle_type(bundle_type())
|
||||||
|
.map(|i| i.name())
|
||||||
|
.unwrap_or("unknown");
|
||||||
|
|
||||||
let url: Url = url
|
let url: Url = url
|
||||||
.to_string()
|
.to_string()
|
||||||
@@ -411,10 +414,12 @@ impl Updater {
|
|||||||
.replace("%7B%7Bcurrent_version%7D%7D", &encoded_version)
|
.replace("%7B%7Bcurrent_version%7D%7D", &encoded_version)
|
||||||
.replace("%7B%7Btarget%7D%7D", target)
|
.replace("%7B%7Btarget%7D%7D", target)
|
||||||
.replace("%7B%7Barch%7D%7D", self.arch)
|
.replace("%7B%7Barch%7D%7D", self.arch)
|
||||||
|
.replace("%7B%7Bbundle_type%7D%7D", installer)
|
||||||
// but not query parameters
|
// but not query parameters
|
||||||
.replace("{{current_version}}", &encoded_version)
|
.replace("{{current_version}}", &encoded_version)
|
||||||
.replace("{{target}}", target)
|
.replace("{{target}}", target)
|
||||||
.replace("{{arch}}", self.arch)
|
.replace("{{arch}}", self.arch)
|
||||||
|
.replace("{{bundle_type}}", installer)
|
||||||
.parse()?;
|
.parse()?;
|
||||||
|
|
||||||
log::debug!("checking for updates {url}");
|
log::debug!("checking for updates {url}");
|
||||||
|
|||||||
Reference in New Issue
Block a user