mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-22 13:38:43 +00:00
Add new variant PkgFmt::Tzstd
and update helpers::extract
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
f555c75e23
commit
5b6634def6
2 changed files with 22 additions and 0 deletions
|
@ -9,6 +9,7 @@ use tar::Archive;
|
||||||
use tinytemplate::TinyTemplate;
|
use tinytemplate::TinyTemplate;
|
||||||
use xz2::read::XzDecoder;
|
use xz2::read::XzDecoder;
|
||||||
use zip::read::ZipArchive;
|
use zip::read::ZipArchive;
|
||||||
|
use zstd::stream::Decoder as ZstdDecoder;
|
||||||
|
|
||||||
use crate::Meta;
|
use crate::Meta;
|
||||||
|
|
||||||
|
@ -102,6 +103,25 @@ pub fn extract<S: AsRef<Path>, P: AsRef<Path>>(
|
||||||
|
|
||||||
txz.unpack(path)?;
|
txz.unpack(path)?;
|
||||||
}
|
}
|
||||||
|
PkgFmt::Tzstd => {
|
||||||
|
// Extract to install dir
|
||||||
|
debug!(
|
||||||
|
"Decompressing from tzstd archive '{:?}' to `{:?}`",
|
||||||
|
source.as_ref(),
|
||||||
|
path.as_ref()
|
||||||
|
);
|
||||||
|
|
||||||
|
let dat = std::fs::File::open(source)?;
|
||||||
|
|
||||||
|
// The error can only come from raw::Decoder::with_dictionary
|
||||||
|
// as of zstd 0.10.2 and 0.11.2, which is specified
|
||||||
|
// as &[] by ZstdDecoder::new, thus ZstdDecoder::new
|
||||||
|
// should not return any error.
|
||||||
|
let tar = ZstdDecoder::new(dat)?;
|
||||||
|
let mut txz = Archive::new(tar);
|
||||||
|
|
||||||
|
txz.unpack(path)?;
|
||||||
|
}
|
||||||
PkgFmt::Zip => {
|
PkgFmt::Zip => {
|
||||||
// Extract to install dir
|
// Extract to install dir
|
||||||
debug!(
|
debug!(
|
||||||
|
|
|
@ -35,6 +35,8 @@ pub enum PkgFmt {
|
||||||
Tgz,
|
Tgz,
|
||||||
/// Download format is TAR + XZ
|
/// Download format is TAR + XZ
|
||||||
Txz,
|
Txz,
|
||||||
|
/// Download format is TAR + Zstd
|
||||||
|
Tzstd,
|
||||||
/// Download format is Zip
|
/// Download format is Zip
|
||||||
Zip,
|
Zip,
|
||||||
/// Download format is raw / binary
|
/// Download format is raw / binary
|
||||||
|
|
Loading…
Add table
Reference in a new issue