Skip to content

Commit 3850779

Browse files
Move recompression out of download
1 parent 0b6a15a commit 3850779

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

src/main.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ impl Context {
161161
// to do. This represents a scenario where changes have been merged to
162162
// the stable/beta branch but the version bump hasn't happened yet.
163163
self.download_artifacts(&rev)?;
164+
// Generate recompressed artifacts from the input set.
165+
self.recompress(&self.dl_dir())?;
164166
// The bypass_startup_checks condition is after the function call since we need that
165167
// function to run even if we wan to discard its output (it fetches and stores the current
166168
// version we're about to release).
@@ -366,31 +368,18 @@ impl Context {
366368
// 2. We're making a stable release. The stable release is first signed
367369
// with the dev key and then it's signed with the prod key later. We
368370
// want the prod key to overwrite the dev key signatures.
369-
//
370-
// Also, collect paths that need to be recompressed
371-
let mut to_recompress = Vec::new();
372371
for file in dl.read_dir()? {
373372
let file = file?;
374373
let path = file.path();
375374
match path.extension().and_then(|s| s.to_str()) {
376-
// Store off the input files for potential recompression.
377-
Some("xz") => {
378-
to_recompress.push(path.to_path_buf());
379-
}
380375
// Delete signature/hash files...
381376
Some("asc") | Some("sha256") => {
382377
fs::remove_file(&path)?;
383378
}
384-
Some("gz") if self.config.recompress_gz => {
385-
fs::remove_file(&path)?;
386-
}
387379
_ => {}
388380
}
389381
}
390382

391-
// Generate recompressed artifacts from the input set.
392-
self.recompress(to_recompress)?;
393-
394383
Ok(())
395384
}
396385

src/recompress.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,28 @@ use crate::Context;
1414
use std::fmt::Write as FmtWrite;
1515
use std::fs::{self, File};
1616
use std::io::{self, Read, Write};
17-
use std::path::PathBuf;
17+
use std::path::Path;
1818
use std::time::{Duration, Instant};
1919
use xz2::read::XzDecoder;
2020

2121
impl Context {
22-
pub fn recompress(&self, mut to_recompress: Vec<PathBuf>) -> anyhow::Result<()> {
22+
pub fn recompress(&self, directory: &Path) -> anyhow::Result<()> {
23+
let mut to_recompress = Vec::new();
24+
for file in directory.read_dir()? {
25+
let file = file?;
26+
let path = file.path();
27+
match path.extension().and_then(|s| s.to_str()) {
28+
// Store off the input files for potential recompression.
29+
Some("xz") => {
30+
to_recompress.push(path.to_path_buf());
31+
}
32+
Some("gz") if self.config.recompress_gz => {
33+
fs::remove_file(&path)?;
34+
}
35+
_ => {}
36+
}
37+
}
38+
2339
println!(
2440
"starting to recompress {} files across {} threads",
2541
to_recompress.len(),

0 commit comments

Comments
 (0)