diff options
| author | 2026-01-13 17:54:42 +0800 | |
|---|---|---|
| committer | 2026-01-13 17:54:42 +0800 | |
| commit | 50f4725c657c6583452d9c85f9b934c3cf2a0f70 (patch) | |
| tree | 8d8de216b134a04507d68dd2dc7516b8dbe433bd /src-tauri/src/utils/zip.rs | |
| parent | f7cabe5a0388518be50eb225500b7b4800109274 (diff) | |
| download | DropOut-50f4725c657c6583452d9c85f9b934c3cf2a0f70.tar.gz DropOut-50f4725c657c6583452d9c85f9b934c3cf2a0f70.zip | |
chore(style): format code
Diffstat (limited to 'src-tauri/src/utils/zip.rs')
| -rw-r--r-- | src-tauri/src/utils/zip.rs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src-tauri/src/utils/zip.rs b/src-tauri/src/utils/zip.rs index 3ddf0f2..a03c975 100644 --- a/src-tauri/src/utils/zip.rs +++ b/src-tauri/src/utils/zip.rs @@ -1,12 +1,16 @@ -use std::path::Path; use std::fs; +use std::path::Path; pub fn extract_zip(zip_path: &Path, extract_to: &Path) -> Result<(), String> { - let file = fs::File::open(zip_path).map_err(|e| format!("Failed to open zip {}: {}", zip_path.display(), e))?; - let mut archive = zip::ZipArchive::new(file).map_err(|e| format!("Failed to read zip: {}", e))?; + let file = fs::File::open(zip_path) + .map_err(|e| format!("Failed to open zip {}: {}", zip_path.display(), e))?; + let mut archive = + zip::ZipArchive::new(file).map_err(|e| format!("Failed to read zip: {}", e))?; for i in 0..archive.len() { - let mut file = archive.by_index(i).map_err(|e| format!("Failed to read zip entry: {}", e))?; + let mut file = archive + .by_index(i) + .map_err(|e| format!("Failed to read zip entry: {}", e))?; let outpath = match file.enclosed_name() { Some(path) => extract_to.join(path), None => continue, @@ -22,11 +26,13 @@ pub fn extract_zip(zip_path: &Path, extract_to: &Path) -> Result<(), String> { } else { if let Some(p) = outpath.parent() { if !p.exists() { - fs::create_dir_all(&p).map_err(|e| format!("Failed to create dir: {}", e))?; + fs::create_dir_all(p).map_err(|e| format!("Failed to create dir: {}", e))?; } } - let mut outfile = fs::File::create(&outpath).map_err(|e| format!("Failed to create file: {}", e))?; - std::io::copy(&mut file, &mut outfile).map_err(|e| format!("Failed to copy file: {}", e))?; + let mut outfile = + fs::File::create(&outpath).map_err(|e| format!("Failed to create file: {}", e))?; + std::io::copy(&mut file, &mut outfile) + .map_err(|e| format!("Failed to copy file: {}", e))?; } } |