Skip to content

Commit a6bd194

Browse files
committed
refactor: use bzip2-rs instead of bzip2 crate
This avoids a dynamic link dependency with libbz2, which is desirable for building portable StGit binaries.
1 parent 947c104 commit a6bd194

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

Cargo.lock

Lines changed: 6 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ termcolor = "1.1"
4444
thiserror = "~1.0"
4545
time = { version = "0.3.21", default-features = false, features = ["local-offset", "formatting", "macros", "parsing"] }
4646

47-
bzip2 = { version = "0.4", optional = true }
47+
bzip2-rs = { version = "0.1", optional = true }
4848
curl = { version = "0.4", optional = true }
4949
flate2 = { version = "1", optional = true }
5050
tar = { version = "0.4", optional = true }
5151

5252
[features]
5353
default = ["import-compressed", "import-url"]
54-
import-compressed = ["dep:bzip2", "dep:flate2", "dep:tar"]
54+
import-compressed = ["dep:bzip2-rs", "dep:flate2", "dep:tar"]
5555
import-url = ["dep:curl"]
5656

5757
[profile.for-pkg]

src/cmd/import.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ fn import_tgz_series(stack: Stack, matches: &clap::ArgMatches, source_path: &Pat
325325
#[cfg(feature = "import-compressed")]
326326
fn import_tbz2_series(stack: Stack, matches: &clap::ArgMatches, source_path: &Path) -> Result<()> {
327327
let source_file = std::fs::File::open(source_path)?;
328-
let mut archive = tar::Archive::new(bzip2::read::BzDecoder::new(source_file));
328+
let mut archive = tar::Archive::new(bzip2_rs::DecoderReader::new(source_file));
329329
let temp_dir = tempfile::tempdir()?;
330330
archive.unpack(temp_dir.path())?;
331331
let series_path = find_series_path(temp_dir.path())?;
@@ -494,7 +494,7 @@ fn read_gz(_source_file: std::fs::File, _content: &mut Vec<u8>) -> Result<()> {
494494

495495
#[cfg(feature = "import-compressed")]
496496
fn read_bz2(source_file: std::fs::File, content: &mut Vec<u8>) -> Result<()> {
497-
bzip2::read::BzDecoder::new(source_file).read_to_end(content)?;
497+
bzip2_rs::DecoderReader::new(source_file).read_to_end(content)?;
498498
Ok(())
499499
}
500500

0 commit comments

Comments
 (0)