Can compress raw files
This commit is contained in:
		@@ -212,6 +212,45 @@ impl DiskFileInfo {
 | 
				
			|||||||
                cmd
 | 
					                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
 | 
					            // 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);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -226,6 +226,15 @@ function DiskImageList(p: {
 | 
				
			|||||||
      field: "format",
 | 
					      field: "format",
 | 
				
			||||||
      headerName: "Format",
 | 
					      headerName: "Format",
 | 
				
			||||||
      flex: 1,
 | 
					      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",
 | 
					      field: "file_size",
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user