Fixing up the Rust side to pass the staged_user_id through

This commit is contained in:
Kevin Bost
2025-02-13 20:57:56 -08:00
committed by Caelan
parent ba8ffbc996
commit 3e7e36d3e7
7 changed files with 40 additions and 15 deletions

23
Cargo.lock generated
View File

@@ -2155,6 +2155,28 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" 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]] [[package]]
name = "value-bag" name = "value-bag"
version = "1.10.0" version = "1.10.0"
@@ -2185,6 +2207,7 @@ dependencies = [
"ts-rs", "ts-rs",
"ureq", "ureq",
"url", "url",
"uuid",
"windows", "windows",
"xml", "xml",
"zip", "zip",

View File

@@ -82,6 +82,7 @@ cbindgen = "0.28"
log-panics = "2.1.0" log-panics = "2.1.0"
core-foundation = "0.10" core-foundation = "0.10"
core-foundation-sys = "0.8" core-foundation-sys = "0.8"
uuid = { version = "1.13.1", features = ["v4", "fast-rng", "macro-diagnostics"] }
# default to small, optimized workspace release binaries # default to small, optimized workspace release binaries
[profile.release] [profile.release]

View File

@@ -36,7 +36,7 @@ unsafe impl Send for CCallbackUpdateSource {}
unsafe impl Sync for CCallbackUpdateSource {} unsafe impl Sync for CCallbackUpdateSource {}
impl UpdateSource for CCallbackUpdateSource { impl UpdateSource for CCallbackUpdateSource {
fn get_release_feed(&self, channel: &str, _: &Manifest) -> Result<VelopackAssetFeed, Error> { fn get_release_feed(&self, channel: &str, _: &Manifest, _staged_user_id: &str) -> Result<VelopackAssetFeed, Error> {
let releases_name = format!("releases.{}.json", channel); let releases_name = format!("releases.{}.json", channel);
let releases_name_cstr = CString::new(releases_name).unwrap(); let releases_name_cstr = CString::new(releases_name).unwrap();

View File

@@ -48,7 +48,7 @@ bitflags.workspace = true
rand.workspace = true rand.workspace = true
sha1.workspace = true sha1.workspace = true
sha2.workspace = true sha2.workspace = true
guid_create = true uuid.workspace = true
# typescript # typescript
ts-rs = { workspace = true, optional = true } ts-rs = { workspace = true, optional = true }

View File

@@ -1,6 +1,7 @@
use std::path::PathBuf; use std::path::PathBuf;
use semver::Version; use semver::Version;
use guid_create::GUID; use uuid::Uuid;
use crate::{ use crate::{
bundle::{self, Manifest}, bundle::{self, Manifest},
util, Error, util, Error,
@@ -306,9 +307,9 @@ impl VelopackLocator {
return beta_id; 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"); std::fs::write(&beta_id_path, &new_id).expect("Unable to write .betaId file");
new_id new_id.to_string()
} }
} }

View File

@@ -238,9 +238,9 @@ impl UpdateManager {
} }
/// Get a list of available remote releases from the package source. /// Get a list of available remote releases from the package source.
pub fn get_release_feed(&self) -> Result<VelopackAssetFeed, Error> { pub fn get_release_feed(&self, staged_user_id: &str) -> Result<VelopackAssetFeed, Error> {
let channel = self.get_practical_channel(); 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. /// 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_channel = self.locator.get_manifest_channel();
let app_version = self.locator.get_manifest_version(); let app_version = self.locator.get_manifest_version();
let staged_user_id = self.locator.get_staged_user_id(); 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 assets = feed.Assets;
let practical_channel = self.get_practical_channel(); let practical_channel = self.get_practical_channel();

View File

@@ -12,7 +12,7 @@ use crate::bundle::Manifest;
pub trait UpdateSource: Send + Sync { pub trait UpdateSource: Send + Sync {
/// Retrieve the list of available remote releases from the package source. These releases /// Retrieve the list of available remote releases from the package source. These releases
/// can subsequently be downloaded with download_release_entry. /// can subsequently be downloaded with download_release_entry.
fn get_release_feed(&self, channel: &str, app: &bundle::Manifest) -> Result<VelopackAssetFeed, Error>; fn get_release_feed(&self, channel: &str, app: &bundle::Manifest, staged_user_id: &str) -> Result<VelopackAssetFeed, Error>;
/// Download the specified VelopackAsset to the provided local file path. /// Download the specified VelopackAsset to the provided local file path.
fn download_release_entry(&self, asset: &VelopackAsset, local_file: &str, progress_sender: Option<Sender<i16>>) -> Result<(), Error>; fn download_release_entry(&self, asset: &VelopackAsset, local_file: &str, progress_sender: Option<Sender<i16>>) -> Result<(), Error>;
/// Clone the source to create a new lifetime. /// Clone the source to create a new lifetime.
@@ -30,7 +30,7 @@ impl Clone for Box<dyn UpdateSource> {
pub struct NoneSource {} pub struct NoneSource {}
impl UpdateSource for NoneSource { impl UpdateSource for NoneSource {
fn get_release_feed(&self, _channel: &str, _app: &Manifest) -> Result<VelopackAssetFeed, Error> { fn get_release_feed(&self, _channel: &str, _app: &Manifest, _staged_user_id: &str) -> Result<VelopackAssetFeed, Error> {
Err(Error::Generic("None source does not checking release feed".to_owned())) 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<Sender<i16>>) -> Result<(), Error> { fn download_release_entry(&self, _asset: &VelopackAsset, _local_file: &str, _progress_sender: Option<Sender<i16>>) -> Result<(), Error> {
@@ -68,8 +68,8 @@ impl AutoSource {
} }
impl UpdateSource for AutoSource { impl UpdateSource for AutoSource {
fn get_release_feed(&self, channel: &str, app: &bundle::Manifest) -> Result<VelopackAssetFeed, Error> { fn get_release_feed(&self, channel: &str, app: &bundle::Manifest, staged_user_id: &str) -> Result<VelopackAssetFeed, Error> {
self.source.get_release_feed(channel, app) self.source.get_release_feed(channel, app, staged_user_id)
} }
fn download_release_entry(&self, asset: &VelopackAsset, local_file: &str, progress_sender: Option<Sender<i16>>) -> Result<(), Error> { fn download_release_entry(&self, asset: &VelopackAsset, local_file: &str, progress_sender: Option<Sender<i16>>) -> Result<(), Error> {
@@ -97,13 +97,13 @@ impl HttpSource {
} }
impl UpdateSource for HttpSource { impl UpdateSource for HttpSource {
fn get_release_feed(&self, channel: &str, app: &bundle::Manifest) -> Result<VelopackAssetFeed, Error> { fn get_release_feed(&self, channel: &str, app: &bundle::Manifest, staged_user_id: &str) -> Result<VelopackAssetFeed, Error> {
let releases_name = format!("releases.{}.json", channel); let releases_name = format!("releases.{}.json", channel);
let path = self.url.trim_end_matches('/').to_owned() + "/"; let path = self.url.trim_end_matches('/').to_owned() + "/";
let url = url::Url::parse(&path)?; let url = url::Url::parse(&path)?;
let mut releases_url = url.join(&releases_name)?; 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()); info!("Downloading releases for channel {} from: {}", channel, releases_url.to_string());
let json = download::download_url_as_string(releases_url.as_str())?; let json = download::download_url_as_string(releases_url.as_str())?;
@@ -146,7 +146,7 @@ impl FileSource {
} }
impl UpdateSource for FileSource { impl UpdateSource for FileSource {
fn get_release_feed(&self, channel: &str, _: &bundle::Manifest) -> Result<VelopackAssetFeed, Error> { fn get_release_feed(&self, channel: &str, _: &bundle::Manifest, _staged_user_id: &str) -> Result<VelopackAssetFeed, Error> {
let releases_name = format!("releases.{}.json", channel); let releases_name = format!("releases.{}.json", channel);
let releases_path = self.path.join(&releases_name); let releases_path = self.path.join(&releases_name);