diff --git a/Cargo.lock b/Cargo.lock index 8a73d208..a8ab54dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2155,6 +2155,28 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "uuid" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced87ca4be083373936a67f8de945faa23b6b42384bd5b64434850802c6dccd0" +dependencies = [ + "getrandom 0.3.1", + "rand", + "uuid-macro-internal", +] + +[[package]] +name = "uuid-macro-internal" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d28dd23acb5f2fa7bd2155ab70b960e770596b3bb6395119b40476c3655dfba4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + [[package]] name = "value-bag" version = "1.10.0" @@ -2185,6 +2207,7 @@ dependencies = [ "ts-rs", "ureq", "url", + "uuid", "windows", "xml", "zip", diff --git a/Cargo.toml b/Cargo.toml index 3480cdd5..d28e9e0a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,6 +82,7 @@ cbindgen = "0.28" log-panics = "2.1.0" core-foundation = "0.10" core-foundation-sys = "0.8" +uuid = { version = "1.13.1", features = ["v4", "fast-rng", "macro-diagnostics"] } # default to small, optimized workspace release binaries [profile.release] diff --git a/src/lib-cpp/src/csource.rs b/src/lib-cpp/src/csource.rs index c03c87fe..40b21340 100644 --- a/src/lib-cpp/src/csource.rs +++ b/src/lib-cpp/src/csource.rs @@ -36,7 +36,7 @@ unsafe impl Send for CCallbackUpdateSource {} unsafe impl Sync for CCallbackUpdateSource {} impl UpdateSource for CCallbackUpdateSource { - fn get_release_feed(&self, channel: &str, _: &Manifest) -> Result { + fn get_release_feed(&self, channel: &str, _: &Manifest, _staged_user_id: &str) -> Result { let releases_name = format!("releases.{}.json", channel); let releases_name_cstr = CString::new(releases_name).unwrap(); diff --git a/src/lib-rust/Cargo.toml b/src/lib-rust/Cargo.toml index 27a30b94..b608a332 100644 --- a/src/lib-rust/Cargo.toml +++ b/src/lib-rust/Cargo.toml @@ -48,7 +48,7 @@ bitflags.workspace = true rand.workspace = true sha1.workspace = true sha2.workspace = true -guid_create = true +uuid.workspace = true # typescript ts-rs = { workspace = true, optional = true } diff --git a/src/lib-rust/src/locator.rs b/src/lib-rust/src/locator.rs index 45277b9a..2fc0ba53 100644 --- a/src/lib-rust/src/locator.rs +++ b/src/lib-rust/src/locator.rs @@ -1,6 +1,7 @@ use std::path::PathBuf; use semver::Version; -use guid_create::GUID; +use uuid::Uuid; + use crate::{ bundle::{self, Manifest}, util, Error, @@ -306,9 +307,9 @@ impl VelopackLocator { return beta_id; } } - let new_id = GUID::rand(); + let new_id = Uuid::new_v4(); std::fs::write(&beta_id_path, &new_id).expect("Unable to write .betaId file"); - new_id + new_id.to_string() } } diff --git a/src/lib-rust/src/manager.rs b/src/lib-rust/src/manager.rs index 8e0ac01e..be9a6a59 100644 --- a/src/lib-rust/src/manager.rs +++ b/src/lib-rust/src/manager.rs @@ -238,9 +238,9 @@ impl UpdateManager { } /// Get a list of available remote releases from the package source. - pub fn get_release_feed(&self) -> Result { + pub fn get_release_feed(&self, staged_user_id: &str) -> Result { let channel = self.get_practical_channel(); - self.source.get_release_feed(&channel, &self.locator.get_manifest()) + self.source.get_release_feed(&channel, &self.locator.get_manifest(), &staged_user_id) } /// Get a list of available remote releases from the package source. @@ -257,7 +257,7 @@ impl UpdateManager { let app_channel = self.locator.get_manifest_channel(); let app_version = self.locator.get_manifest_version(); let staged_user_id = self.locator.get_staged_user_id(); - let feed = self.get_release_feed()?; + let feed = self.get_release_feed(&staged_user_id)?; let assets = feed.Assets; let practical_channel = self.get_practical_channel(); diff --git a/src/lib-rust/src/sources.rs b/src/lib-rust/src/sources.rs index 3e90851f..635bc2bb 100644 --- a/src/lib-rust/src/sources.rs +++ b/src/lib-rust/src/sources.rs @@ -12,7 +12,7 @@ use crate::bundle::Manifest; pub trait UpdateSource: Send + Sync { /// Retrieve the list of available remote releases from the package source. These releases /// can subsequently be downloaded with download_release_entry. - fn get_release_feed(&self, channel: &str, app: &bundle::Manifest) -> Result; + fn get_release_feed(&self, channel: &str, app: &bundle::Manifest, staged_user_id: &str) -> Result; /// Download the specified VelopackAsset to the provided local file path. fn download_release_entry(&self, asset: &VelopackAsset, local_file: &str, progress_sender: Option>) -> Result<(), Error>; /// Clone the source to create a new lifetime. @@ -30,7 +30,7 @@ impl Clone for Box { pub struct NoneSource {} impl UpdateSource for NoneSource { - fn get_release_feed(&self, _channel: &str, _app: &Manifest) -> Result { + fn get_release_feed(&self, _channel: &str, _app: &Manifest, _staged_user_id: &str) -> Result { Err(Error::Generic("None source does not checking release feed".to_owned())) } fn download_release_entry(&self, _asset: &VelopackAsset, _local_file: &str, _progress_sender: Option>) -> Result<(), Error> { @@ -68,8 +68,8 @@ impl AutoSource { } impl UpdateSource for AutoSource { - fn get_release_feed(&self, channel: &str, app: &bundle::Manifest) -> Result { - self.source.get_release_feed(channel, app) + fn get_release_feed(&self, channel: &str, app: &bundle::Manifest, staged_user_id: &str) -> Result { + self.source.get_release_feed(channel, app, staged_user_id) } fn download_release_entry(&self, asset: &VelopackAsset, local_file: &str, progress_sender: Option>) -> Result<(), Error> { @@ -97,13 +97,13 @@ impl HttpSource { } impl UpdateSource for HttpSource { - fn get_release_feed(&self, channel: &str, app: &bundle::Manifest) -> Result { + fn get_release_feed(&self, channel: &str, app: &bundle::Manifest, staged_user_id: &str) -> Result { let releases_name = format!("releases.{}.json", channel); let path = self.url.trim_end_matches('/').to_owned() + "/"; let url = url::Url::parse(&path)?; let mut releases_url = url.join(&releases_name)?; - releases_url.set_query(Some(format!("localVersion={}&id={}", app.version, app.id).as_str())); + releases_url.set_query(Some(format!("localVersion={}&id={}&stagingId={}", app.version, app.id, staged_user_id).as_str())); info!("Downloading releases for channel {} from: {}", channel, releases_url.to_string()); let json = download::download_url_as_string(releases_url.as_str())?; @@ -146,7 +146,7 @@ impl FileSource { } impl UpdateSource for FileSource { - fn get_release_feed(&self, channel: &str, _: &bundle::Manifest) -> Result { + fn get_release_feed(&self, channel: &str, _: &bundle::Manifest, _staged_user_id: &str) -> Result { let releases_name = format!("releases.{}.json", channel); let releases_path = self.path.join(&releases_name);