From f7431ca6a4a5f8e208c061f1c4915f9ea46b3f07 Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Sat, 15 Jan 2022 21:40:36 -0800 Subject: [PATCH] Clippy --- web/src/decrypt.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/web/src/decrypt.rs b/web/src/decrypt.rs index bcbc493..9ac4bbb 100644 --- a/web/src/decrypt.rs +++ b/web/src/decrypt.rs @@ -126,24 +126,22 @@ fn handle_gzip(blob: Arc, container: Vec) -> DecryptedData { let gzip_dec = flate2::read::GzDecoder::new(cursor); let mut archive = tar::Archive::new(gzip_dec); if let Ok(files) = archive.entries() { - for file in files { - if let Ok(file) = file { - let file_path = if let Ok(file_path) = file.path() { - file_path.display().to_string() - } else { - "".to_string() - }; - entries.push(ArchiveMeta { - name: file_path, - file_size: file.size(), - }); - } + for file in files.flatten() { + let file_path = if let Ok(file_path) = file.path() { + file_path.display().to_string() + } else { + "".to_string() + }; + entries.push(ArchiveMeta { + name: file_path, + file_size: file.size(), + }); } } - if entries.len() > 0 { - DecryptedData::Archive(blob, entries) - } else { + if entries.is_empty() { DecryptedData::Blob(blob) + } else { + DecryptedData::Archive(blob, entries) } }