Skip to content

Split download verify parts of download_sysext into separate module#87

Merged
dongsupark merged 1 commit intomainfrom
dongsu/split-download
Sep 17, 2025
Merged

Split download verify parts of download_sysext into separate module#87
dongsupark merged 1 commit intomainfrom
dongsu/split-download

Conversation

@dongsupark
Copy link
Member

To be able to make package-related structs and enums public, Package and PackageStatus, create a new module download, move download.rs to download/mod.rs, create download/packge.rs that includes all package-related structs and enums.

To make download and verify functions of download_sysext usable by other modules, move most code parts into the new download module.

It is a preparation for the server-client architecture issue, #75 which I am working on.

@dongsupark dongsupark force-pushed the dongsu/split-download branch from 15d3757 to a356548 Compare September 11, 2025 13:25
@dongsupark
Copy link
Member Author

A manual test passed. so no regression.

RUST_LOG=debug target/debug/download_sysext \
  -p ~/Dev/flatcar-scripts/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-au-key/files/official-v2.pub.pem \
  -m oem-azure.gz \
  -o /var/tmp/outdir/ \
  -u https://update.release.flatcar-linux.net/amd64-usr/4426.0.0/oem-azure.gz

@dongsupark dongsupark marked this pull request as ready for review September 11, 2025 14:00
@dongsupark dongsupark requested a review from a team as a code owner September 11, 2025 14:00
Copy link
Contributor

@james-parky james-parky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems sensible to extract to a new struct as method, with changes. However, there will be conflicts with my #88 if that is approved.

pub data: File,
}

pub fn hash_on_disk<T: omaha::HashAlgo>(path: &Path, maxlen: Option<usize>) -> Result<omaha::Hash<T>> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice pattern to use a generic of <P: AsRef<Path>> when args are something that should be a path.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a nice improvement, but that results in a huge change, so I would do in a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes i would recommend it elsewhere in the codebase as well where appropriate so valid in separate pr

Copy link
Contributor

@james-parky james-parky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will have conflicts I imagine with #88. But I agree with the changes and don't mind which is merged first.

To be able to make package-related structs and enums public, Package
and PackageStatus, create a new module download, move download.rs to
download/mod.rs, create download/packge.rs that includes all
package-related structs and enums.

To make download and verify functions usable by other modules,
move most code parts into the new download module.

Signed-off-by: Dongsu Park <dongsu@dpark.io>
@dongsupark dongsupark force-pushed the dongsu/split-download branch from aa2d002 to a5ae9b6 Compare September 17, 2025 09:42
@dongsupark
Copy link
Member Author

Squashed commits. Thanks!

@dongsupark dongsupark merged commit c6e869f into main Sep 17, 2025
4 checks passed
@dongsupark dongsupark deleted the dongsu/split-download branch September 17, 2025 09:44
james-parky added a commit to james-parky/ue-rs that referenced this pull request Sep 18, 2025
PR flatcar#87 created the download crate which caused merge conflicts with flatcar#88.
james-parky added a commit to james-parky/ue-rs that referenced this pull request Sep 18, 2025
PR flatcar#87 created the download crate which caused merge conflicts with flatcar#88.

Signed-off-by: james-parky <72101291+james-parky@users.noreply.github.com>
dongsupark added a commit to flatcar/scripts that referenced this pull request Sep 26, 2025
dongsupark added a commit to flatcar/scripts that referenced this pull request Sep 26, 2025
dongsupark added a commit to flatcar/scripts that referenced this pull request Sep 26, 2025
dongsupark added a commit that referenced this pull request Sep 26, 2025
Before PR #87, target_filename was
almost always `None`, which had covered an issue of setting pkg_verified.
In case of target_filename being a valid String, for example
"oem-azure.gz", pkg_verified ended up having an extension `.gz`, which
is not expected.

Now that the PR was merged, DownloadVerify module gets created with
.target_filename(args.target_filename.unwrap_or(TARGET_FILENAME_DEFAULT.into())),
where TARGET_FILENAME_DEFAULT is with ".gz" extension. That uncovered
the hidden issue.

Fix that with explicitly setting extension ".raw" for both a valid
String and None for the input string.

Signed-off-by: Dongsu Park <dongsu@dpark.io>
dongsupark added a commit to flatcar/scripts that referenced this pull request Sep 26, 2025
dongsupark added a commit to flatcar/scripts that referenced this pull request Sep 27, 2025
dongsupark added a commit to flatcar/scripts that referenced this pull request Sep 27, 2025
dongsupark added a commit to flatcar/scripts that referenced this pull request Sep 30, 2025
cnd4 pushed a commit to cnd4/flatcar-scripts that referenced this pull request Oct 3, 2025
dongsupark added a commit that referenced this pull request Oct 13, 2025
When --input-xml is on and --payload-url is off to pass XML data
offline, we need to set payload_url to None and continue running
the DownloadVerify builder instead of returning there.

It is necessary to fix regressions of
#87.

Signed-off-by: Dongsu Park <dongsu@dpark.io>
dongsupark added a commit that referenced this pull request Dec 10, 2025
Before PR #87, target_filename was
almost always `None`, which had covered an issue of setting pkg_verified.
In case of target_filename being a valid String, for example
"oem-azure.gz", pkg_verified ended up having an extension `.gz`, which
is not expected.

Now that the PR was merged, DownloadVerify module gets created with
.target_filename(args.target_filename.unwrap_or(TARGET_FILENAME_DEFAULT.into())),
where TARGET_FILENAME_DEFAULT is with ".gz" extension. That uncovered
the hidden issue.

Fix that with explicitly setting extension ".raw" for both a valid
String and None for the input string.

Signed-off-by: Dongsu Park <dongsu@dpark.io>
dongsupark pushed a commit that referenced this pull request Dec 10, 2025
PR #87 created the download crate which caused merge conflicts with #88.

Signed-off-by: james-parky <72101291+james-parky@users.noreply.github.com>
dongsupark added a commit that referenced this pull request Dec 10, 2025
When --input-xml is on and --payload-url is off to pass XML data
offline, we need to set payload_url to None and continue running
the DownloadVerify builder instead of returning there.

It is necessary to fix regressions of
#87.

Signed-off-by: Dongsu Park <dongsu@dpark.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants