From d9e1e3cc45ef5bee2e81cc9d45395ea0c76cfb5f Mon Sep 17 00:00:00 2001 From: Aleksei Fedotov <102949797+alekseifedotov@users.noreply.github.com> Date: Fri, 13 Dec 2024 22:55:48 +0100 Subject: [PATCH] fix: OTA from local path (#330) update-agent could download OTA from a local directory. If the images are compress, update-agent tries to decompress files in the same directory where the source image is, instead of /mnt/downloads. This commit makes update-agent decompress the images in /mnt/downloads. --- update-agent/src/component.rs | 8 ++++---- update-agent/src/main.rs | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/update-agent/src/component.rs b/update-agent/src/component.rs index 45762362..98821749 100644 --- a/update-agent/src/component.rs +++ b/update-agent/src/component.rs @@ -82,8 +82,8 @@ impl Component { self.manifest_component.name() } - fn process_compressed(&mut self) -> eyre::Result<()> { - let uncompressed_path = self.on_disk.with_extension("uncompressed"); + fn process_compressed(&mut self, dst: &Path) -> eyre::Result<()> { + let uncompressed_path = dst.with_extension("uncompressed"); let uncompressed_path_verified = get_verified_component_path(&uncompressed_path); @@ -156,9 +156,9 @@ impl Component { Ok(()) } - pub fn process(&mut self) -> eyre::Result<()> { + pub fn process(&mut self, dst: &Path) -> eyre::Result<()> { match self.source.mime_type { - MimeType::XZ => self.process_compressed(), + MimeType::XZ => self.process_compressed(dst), MimeType::OctetStream => Ok(()), } } diff --git a/update-agent/src/main.rs b/update-agent/src/main.rs index 110c77d2..92f2805f 100644 --- a/update-agent/src/main.rs +++ b/update-agent/src/main.rs @@ -353,21 +353,21 @@ pub fn validate_claim( Ok(()) } -fn fetch_update_components>( +fn fetch_update_components( claim: &Claim, - manifest_dst: P, - dst: P, + manifest_dst: &Path, + dst: &Path, supervisor_proxy: Option<&dbus::SupervisorProxyBlocking<'static>>, download_delay: Duration, ) -> eyre::Result> { - orb_update_agent::manifest::compare_to_disk(claim.manifest(), &manifest_dst)?; + orb_update_agent::manifest::compare_to_disk(claim.manifest(), manifest_dst)?; let mut components = Vec::with_capacity(claim.num_components()); for (component, source) in claim.iter_components_with_location() { let component = component::fetch( component, &claim.system_components()[component.name()], source, - &dst, + dst, supervisor_proxy, download_delay, ) @@ -379,7 +379,7 @@ fn fetch_update_components>( components .iter_mut() .try_for_each(|comp| { - comp.process().wrap_err_with(|| { + comp.process(dst).wrap_err_with(|| { format!( "failed to process update file for component `{}`", comp.name(),