Skip to content

Commit c34b2eb

Browse files
authored
添加tar.xz的支持 (#18)
1 parent bc00399 commit c34b2eb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/executor/source.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ impl ArchiveFile {
461461
let archive_name = archive_path.file_name().unwrap().to_str().unwrap();
462462
for (regex, archivetype) in [
463463
(Regex::new(r"^(.+)\.tar\.gz$").unwrap(), ArchiveType::TarGz),
464+
(Regex::new(r"^(.+)\.tar\.xz$").unwrap(), ArchiveType::TarXz),
464465
(Regex::new(r"^(.+)\.zip$").unwrap(), ArchiveType::Zip),
465466
] {
466467
if regex.is_match(archive_name) {
@@ -500,9 +501,9 @@ impl ArchiveFile {
500501
}
501502
//根据压缩文件的类型生成cmd指令
502503
match &self.archive_type {
503-
ArchiveType::TarGz => {
504+
ArchiveType::TarGz | ArchiveType::TarXz => {
504505
let mut cmd = Command::new("tar");
505-
cmd.arg("-xzf").arg(&self.archive_name);
506+
cmd.arg("-xf").arg(&self.archive_name);
506507
let proc: std::process::Child = cmd
507508
.current_dir(path)
508509
.stderr(Stdio::piped())
@@ -575,6 +576,7 @@ impl ArchiveFile {
575576

576577
pub enum ArchiveType {
577578
TarGz,
579+
TarXz,
578580
Zip,
579581
Undefined,
580582
}

0 commit comments

Comments
 (0)