Skip to content

Commit 18291c2

Browse files
committed
Remove -v/--print-progress option
The detailed report depended on async downloading which is gone and the current reporting is a single line print, not worth maintaining this command line option for.
1 parent fa5202f commit 18291c2

File tree

4 files changed

+12
-44
lines changed

4 files changed

+12
-44
lines changed

examples/download_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn main() -> Result<(), Box<dyn Error>> {
1313

1414
let tempdir = tempfile::tempdir()?;
1515
let path = tempdir.path().join("tmpfile");
16-
let res = download_and_hash(&client, url, &path, None, None, false)?;
16+
let res = download_and_hash(&client, url, &path, None, None)?;
1717
tempdir.close()?;
1818

1919
println!("hash: {}", res.hash_sha256);

examples/full_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fn main() -> Result<(), Box<dyn Error>> {
8080

8181
let tempdir = tempfile::tempdir()?;
8282
let path = tempdir.path().join("tmpfile");
83-
let res = ue_rs::download_and_hash(&client, url.clone(), &path, Some(expected_sha256.clone()), None, false).context(format!("download_and_hash({url:?}) failed"))?;
83+
let res = ue_rs::download_and_hash(&client, url.clone(), &path, Some(expected_sha256.clone()), None).context(format!("download_and_hash({url:?}) failed"))?;
8484
tempdir.close()?;
8585

8686
println!("\texpected sha256: {}", expected_sha256);

src/bin/download_sysext.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'a> Package<'a> {
9898
Ok(())
9999
}
100100

101-
fn download(&mut self, into_dir: &Path, client: &Client, print_progress: bool) -> Result<()> {
101+
fn download(&mut self, into_dir: &Path, client: &Client) -> Result<()> {
102102
// FIXME: use _range_start for completing downloads
103103
let _range_start = match self.status {
104104
PackageStatus::ToDownload => 0,
@@ -115,7 +115,6 @@ impl<'a> Package<'a> {
115115
&path,
116116
self.hash_sha256.clone(),
117117
self.hash_sha1.clone(),
118-
print_progress,
119118
) {
120119
Ok(ok) => ok,
121120
Err(err) => {
@@ -251,12 +250,12 @@ fn get_pkgs_to_download<'a>(resp: &'a omaha::Response, glob_set: &GlobSet)
251250
}
252251

253252
// Read data from remote URL into File
254-
fn fetch_url_to_file<'a, U>(path: &'a Path, input_url: U, client: &'a Client, print_progress: bool) -> Result<Package<'a>>
253+
fn fetch_url_to_file<'a, U>(path: &'a Path, input_url: U, client: &'a Client) -> Result<Package<'a>>
255254
where
256255
U: reqwest::IntoUrl + From<U> + std::clone::Clone + std::fmt::Debug,
257256
Url: From<U>,
258257
{
259-
let r = ue_rs::download_and_hash(client, input_url.clone(), path, None, None, print_progress).context(format!("unable to download data(url {:?})", input_url))?;
258+
let r = ue_rs::download_and_hash(client, input_url.clone(), path, None, None).context(format!("unable to download data(url {:?})", input_url))?;
260259

261260
Ok(Package {
262261
name: Cow::Borrowed(path.file_name().unwrap_or(OsStr::new("fakepackage")).to_str().unwrap_or("fakepackage")),
@@ -268,10 +267,10 @@ where
268267
})
269268
}
270269

271-
fn do_download_verify(pkg: &mut Package<'_>, output_filename: Option<String>, output_dir: &Path, unverified_dir: &Path, pubkey_file: &str, client: &Client, print_progress: bool) -> Result<()> {
270+
fn do_download_verify(pkg: &mut Package<'_>, output_filename: Option<String>, output_dir: &Path, unverified_dir: &Path, pubkey_file: &str, client: &Client) -> Result<()> {
272271
pkg.check_download(unverified_dir)?;
273272

274-
pkg.download(unverified_dir, client, print_progress).context(format!("unable to download \"{:?}\"", pkg.name))?;
273+
pkg.download(unverified_dir, client).context(format!("unable to download \"{:?}\"", pkg.name))?;
275274

276275
// Unverified payload is stored in e.g. "output_dir/.unverified/oem.gz".
277276
// Verified payload is stored in e.g. "output_dir/oem.raw".
@@ -319,10 +318,6 @@ struct Args {
319318
/// only take the first matching entry
320319
#[argh(switch, short = 't')]
321320
take_first_match: bool,
322-
323-
/// report download progress
324-
#[argh(switch, short = 'v')]
325-
print_progress: bool,
326321
}
327322

328323
impl Args {
@@ -399,7 +394,6 @@ fn main() -> Result<(), Box<dyn Error>> {
399394
&temp_payload_path,
400395
Url::from_str(url.as_str()).context(anyhow!("failed to convert into url ({:?})", url))?,
401396
&client,
402-
args.print_progress,
403397
)?;
404398
do_download_verify(
405399
&mut pkg_fake,
@@ -408,7 +402,6 @@ fn main() -> Result<(), Box<dyn Error>> {
408402
unverified_dir.as_path(),
409403
args.pubkey_file.as_str(),
410404
&client,
411-
args.print_progress,
412405
)?;
413406

414407
// verify only a fake package, early exit and skip the rest.
@@ -442,7 +435,6 @@ fn main() -> Result<(), Box<dyn Error>> {
442435
unverified_dir.as_path(),
443436
args.pubkey_file.as_str(),
444437
&client,
445-
args.print_progress,
446438
)?;
447439
if args.take_first_match {
448440
break;

src/download.rs

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,7 @@ pub fn hash_on_disk<T: omaha::HashAlgo>(path: &Path, maxlen: Option<usize>) -> R
5959
Ok(omaha::Hash::from_bytes(Box::new(hasher).finalize()))
6060
}
6161

62-
fn do_download_and_hash<U>(
63-
client: &Client,
64-
url: U,
65-
path: &Path,
66-
expected_sha256: Option<omaha::Hash<omaha::Sha256>>,
67-
expected_sha1: Option<omaha::Hash<omaha::Sha1>>,
68-
print_progress: bool,
69-
) -> Result<DownloadResult>
62+
fn do_download_and_hash<U>(client: &Client, url: U, path: &Path, expected_sha256: Option<omaha::Hash<omaha::Sha256>>, expected_sha1: Option<omaha::Hash<omaha::Sha1>>) -> Result<DownloadResult>
7063
where
7164
U: reqwest::IntoUrl + Clone,
7265
Url: From<U>,
@@ -96,9 +89,8 @@ where
9689
}
9790
}
9891

99-
if print_progress {
100-
println!("writing to {}", path.display());
101-
}
92+
println!("writing to {}", path.display());
93+
10294
let mut file = File::create(path).context(format!("failed to create path ({:?})", path.display()))?;
10395
res.copy_to(&mut file)?;
10496

@@ -126,29 +118,13 @@ where
126118
})
127119
}
128120

129-
pub fn download_and_hash<U>(
130-
client: &Client,
131-
url: U,
132-
path: &Path,
133-
expected_sha256: Option<omaha::Hash<omaha::Sha256>>,
134-
expected_sha1: Option<omaha::Hash<omaha::Sha1>>,
135-
print_progress: bool,
136-
) -> Result<DownloadResult>
121+
pub fn download_and_hash<U>(client: &Client, url: U, path: &Path, expected_sha256: Option<omaha::Hash<omaha::Sha256>>, expected_sha1: Option<omaha::Hash<omaha::Sha1>>) -> Result<DownloadResult>
137122
where
138123
U: reqwest::IntoUrl + Clone,
139124
Url: From<U>,
140125
{
141126
crate::retry_loop(
142-
|| {
143-
do_download_and_hash(
144-
client,
145-
url.clone(),
146-
path,
147-
expected_sha256.clone(),
148-
expected_sha1.clone(),
149-
print_progress,
150-
)
151-
},
127+
|| do_download_and_hash(client, url.clone(), path, expected_sha256.clone(), expected_sha1.clone()),
152128
MAX_DOWNLOAD_RETRY,
153129
)
154130
}

0 commit comments

Comments
 (0)