Can decompress raw files to sparse file
This commit is contained in:
@ -129,3 +129,9 @@ pub const COPY_PROGRAM: &str = "/bin/cp";
|
|||||||
|
|
||||||
/// Gzip program path
|
/// Gzip program path
|
||||||
pub const GZIP_PROGRAM: &str = "/usr/bin/gzip";
|
pub const GZIP_PROGRAM: &str = "/usr/bin/gzip";
|
||||||
|
|
||||||
|
/// Bash program
|
||||||
|
pub const BASH_PROGRAM: &str = "/usr/bin/bash";
|
||||||
|
|
||||||
|
/// DD program
|
||||||
|
pub const DD_PROGRAM: &str = "/usr/bin/dd";
|
||||||
|
@ -251,6 +251,20 @@ impl DiskFileInfo {
|
|||||||
cmd
|
cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Decompress Raw to sparse file
|
||||||
|
// https://benou.fr/www/ben/decompressing-sparse-files.html
|
||||||
|
(DiskFileFormat::CompressedRaw, DiskFileFormat::Raw { is_sparse: true }) => {
|
||||||
|
let mut cmd = Command::new(constants::BASH_PROGRAM);
|
||||||
|
cmd.arg("-c").arg(format!(
|
||||||
|
"{} -d -c {} | {} conv=sparse of={}",
|
||||||
|
constants::GZIP_PROGRAM,
|
||||||
|
self.file_path.display(),
|
||||||
|
constants::DD_PROGRAM,
|
||||||
|
temp_file.display()
|
||||||
|
));
|
||||||
|
cmd
|
||||||
|
}
|
||||||
|
|
||||||
// Dumb copy of file
|
// Dumb copy of file
|
||||||
(a, b) if a == b => {
|
(a, b) if a == b => {
|
||||||
let mut cmd = Command::new(constants::COPY_PROGRAM);
|
let mut cmd = Command::new(constants::COPY_PROGRAM);
|
||||||
|
Reference in New Issue
Block a user