Can compress raw files
This commit is contained in:
parent
9822c5a72a
commit
42f22c110c
@ -212,6 +212,45 @@ impl DiskFileInfo {
|
||||
cmd
|
||||
}
|
||||
|
||||
// Render raw file non sparse
|
||||
(DiskFileFormat::Raw { is_sparse: true }, DiskFileFormat::Raw { is_sparse: false }) => {
|
||||
let mut cmd = Command::new(constants::COPY_PROGRAM);
|
||||
cmd.arg("--sparse=never")
|
||||
.arg(&self.file_path)
|
||||
.arg(&temp_file);
|
||||
cmd
|
||||
}
|
||||
|
||||
// Render raw file sparse
|
||||
(DiskFileFormat::Raw { is_sparse: false }, DiskFileFormat::Raw { is_sparse: true }) => {
|
||||
let mut cmd = Command::new(constants::COPY_PROGRAM);
|
||||
cmd.arg("--sparse=always")
|
||||
.arg(&self.file_path)
|
||||
.arg(&temp_file);
|
||||
cmd
|
||||
}
|
||||
|
||||
// Compress Raw
|
||||
(DiskFileFormat::Raw { .. }, DiskFileFormat::CompressedRaw) => {
|
||||
let mut cmd = Command::new(constants::GZIP_PROGRAM);
|
||||
cmd.arg("--keep")
|
||||
.arg("--to-stdout")
|
||||
.arg(&self.file_path)
|
||||
.stdout(File::create(&temp_file)?);
|
||||
cmd
|
||||
}
|
||||
|
||||
// Decompress Raw to not sparse file
|
||||
(DiskFileFormat::CompressedRaw, DiskFileFormat::Raw { is_sparse: false }) => {
|
||||
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);
|
||||
|
@ -226,6 +226,15 @@ function DiskImageList(p: {
|
||||
field: "format",
|
||||
headerName: "Format",
|
||||
flex: 1,
|
||||
renderCell(params) {
|
||||
let content = params.row.format;
|
||||
|
||||
if (params.row.format === "Raw") {
|
||||
content += params.row.is_sparse ? " (Sparse)" : " (Fixed)";
|
||||
}
|
||||
|
||||
return content;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "file_size",
|
||||
|
Loading…
x
Reference in New Issue
Block a user