From 23c8f567fcfe6d0756eae70a603a879f78ba0f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Rodrigues=20Miguel?= Date: Sun, 21 Mar 2021 19:18:32 -0300 Subject: [PATCH] Minor changes in decompressors/zip.rs --- src/decompressors/zip.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/decompressors/zip.rs b/src/decompressors/zip.rs index ba3ec85..cfdd4c9 100644 --- a/src/decompressors/zip.rs +++ b/src/decompressors/zip.rs @@ -40,23 +40,25 @@ impl ZipDecompressor { Self::check_for_comments(&file); - if (&*file.name()).ends_with('/') { + let is_dir = (&*file.name()).ends_with('/'); + + if is_dir { println!("File {} extracted to \"{}\"", idx, file_path.display()); fs::create_dir_all(&file_path)?; } else { + if let Some(p) = file_path.parent() { + if !p.exists() { + fs::create_dir_all(&p)?; + } + } println!( "{}: \"{}\" extracted. ({} bytes)", "info".yellow(), file_path.display(), file.size() ); - if let Some(p) = file_path.parent() { - if !p.exists() { - fs::create_dir_all(&p).unwrap(); - } - } - let mut outfile = fs::File::create(&file_path).unwrap(); - io::copy(&mut file, &mut outfile).unwrap(); + let mut outfile = fs::File::create(&file_path)?; + io::copy(&mut file, &mut outfile)?; } let file_path = fs::canonicalize(file_path.clone())?; @@ -76,7 +78,6 @@ impl Decompressor for ZipDecompressor { let files_unpacked = Self::unpack_files(&from.path, destination_path)?; - // placeholder return Ok(files_unpacked) } } \ No newline at end of file