Skip to content

Commit 2ec9c23

Browse files
committed
download: remove TARGET_FILENAME_DEFAULT, PAYLOAD_URL_DEFAULT
Since the target filename could vary for many update payload types and OEMs, it does not make sense to set a default filename to a specific target file name. Remove TARGET_FILENAME_DEFAULT and PAYLOAD_URL_DEFAULT. Let target_filename() & payload_url() take Option<String> parameter, to be able to pass either Some(String) or None, to fix a wrong target_filename issue. Signed-off-by: Dongsu Park <[email protected]>
1 parent d8ee229 commit 2ec9c23

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

src/bin/download_sysext.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use anyhow::Result;
1010
use argh::FromArgs;
1111
use globset::{Glob, GlobSet, GlobSetBuilder};
1212

13-
use ue_rs::{TARGET_FILENAME_DEFAULT, DownloadVerify};
13+
use ue_rs::DownloadVerify;
1414

1515
#[derive(FromArgs, Debug)]
1616
/// Parse an update-engine Omaha XML response to extract sysext images, then download and verify
@@ -102,9 +102,9 @@ fn main() -> Result<(), Box<dyn Error>> {
102102
let glob_set = args.image_match_glob_set()?;
103103

104104
DownloadVerify::new(args.output_dir, args.pubkey_file, args.take_first_match, glob_set)
105-
.target_filename(args.target_filename.unwrap_or(TARGET_FILENAME_DEFAULT.into()))
105+
.target_filename(args.target_filename)
106106
.input_xml(input_xml.unwrap_or_default())
107-
.payload_url(payload_url.clone())
107+
.payload_url(Some(payload_url.clone()))
108108
.run()?;
109109

110110
Ok(())

src/download/mod.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ const DOWNLOAD_TIMEOUT: u64 = 3600;
2424
const HTTP_CONN_TIMEOUT: u64 = 20;
2525
const MAX_DOWNLOAD_RETRY: u32 = 20;
2626

27-
pub const TARGET_FILENAME_DEFAULT: &str = "oem-azure.gz";
28-
pub const PAYLOAD_URL_DEFAULT: &str = "https://update.release.flatcar-linux.net/amd64-usr/current/oem-azure.gz";
29-
3027
const UNVERFIED_SUFFIX: &str = ".unverified";
3128
const TMP_SUFFIX: &str = ".tmp";
3229

@@ -247,8 +244,8 @@ impl DownloadVerify {
247244
}
248245
}
249246

250-
pub fn target_filename(mut self, param_target_filename: String) -> Self {
251-
self.target_filename = Some(param_target_filename);
247+
pub fn target_filename(mut self, param_target_filename: Option<String>) -> Self {
248+
self.target_filename = param_target_filename;
252249
self
253250
}
254251

@@ -257,8 +254,8 @@ impl DownloadVerify {
257254
self
258255
}
259256

260-
pub fn payload_url(mut self, param_payload_url: String) -> Self {
261-
self.payload_url = Some(param_payload_url);
257+
pub fn payload_url(mut self, param_payload_url: Option<String>) -> Self {
258+
self.payload_url = param_payload_url;
262259
self
263260
}
264261

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
mod download;
2-
pub use download::TARGET_FILENAME_DEFAULT;
3-
pub use download::PAYLOAD_URL_DEFAULT;
42
pub use download::{DownloadResult, DownloadVerify};
53
pub use download::download_and_hash;
64
pub use download::hash_on_disk;

0 commit comments

Comments
 (0)