Can decompress QCow2
This commit is contained in:
@ -126,3 +126,6 @@ pub const IP_PROGRAM: &str = "/usr/sbin/ip";
|
||||
|
||||
/// Copy program path
|
||||
pub const COPY_PROGRAM: &str = "/bin/cp";
|
||||
|
||||
/// Gzip program path
|
||||
pub const GZIP_PROGRAM: &str = "/usr/bin/gzip";
|
||||
|
@ -1,6 +1,7 @@
|
||||
use crate::app_config::AppConfig;
|
||||
use crate::constants;
|
||||
use crate::utils::file_size_utils::FileSize;
|
||||
use std::fs::File;
|
||||
use std::os::linux::fs::MetadataExt;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
@ -156,6 +157,17 @@ impl DiskFileInfo {
|
||||
|
||||
// Prepare the conversion
|
||||
let mut cmd = match (self.format, dest_format) {
|
||||
// Decompress QCow2
|
||||
(DiskFileFormat::CompressedQCow2, DiskFileFormat::QCow2 { .. }) => {
|
||||
let mut cmd = Command::new(constants::GZIP_PROGRAM);
|
||||
cmd.arg("--keep")
|
||||
.arg("--decompress")
|
||||
.arg("--to-stdout")
|
||||
.arg(&self.file_path)
|
||||
.stdout(File::create(&temp_file)?);
|
||||
cmd
|
||||
}
|
||||
|
||||
// Dumb copy of file
|
||||
(a, b) if a == b => {
|
||||
let mut cmd = Command::new(constants::COPY_PROGRAM);
|
||||
|
Reference in New Issue
Block a user