Skip to content

Commit

Permalink
fix: OTA from local path
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alekseifedotov committed Dec 13, 2024
1 parent 998fc03 commit f86937d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions update-agent/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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(()),
}
}
Expand Down
8 changes: 4 additions & 4 deletions update-agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ pub fn validate_claim(
Ok(())
}

fn fetch_update_components<P: AsRef<Path>>(
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<Vec<Component>> {
Expand All @@ -379,7 +379,7 @@ fn fetch_update_components<P: AsRef<Path>>(
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(),
Expand Down

0 comments on commit f86937d

Please sign in to comment.