fix: remove unnecessary clones in zip decryption

This commit is contained in:
ttyS3 2024-09-06 13:55:04 +00:00 committed by João Marcos
parent 309d165606
commit 61868dfb56

View File

@ -45,7 +45,7 @@ where
for idx in 0..archive.len() {
let mut file = match password {
Some(password) => archive
.by_index_decrypt(idx, password.to_owned().as_bytes())?
.by_index_decrypt(idx, password.as_bytes())?
.map_err(|_| zip::result::ZipError::UnsupportedArchive("Password required to decrypt file"))?,
None => archive.by_index(idx)?,
};
@ -127,8 +127,7 @@ where
let maybe_file_in_archive = (|| {
let zip_result = match password.clone() {
Some(password) => archive
.by_index_decrypt(idx, password.to_owned().clone().as_bytes())
.unwrap()
.by_index_decrypt(idx, password.as_bytes()).ok()?
.map_err(|_| zip::result::ZipError::UnsupportedArchive("Password required to decrypt file")),
None => archive.by_index(idx),
};