mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 19:45:29 +00:00
fix: remove unnecessary clones in zip decryption
This commit is contained in:
parent
309d165606
commit
61868dfb56
@ -45,7 +45,7 @@ where
|
|||||||
for idx in 0..archive.len() {
|
for idx in 0..archive.len() {
|
||||||
let mut file = match password {
|
let mut file = match password {
|
||||||
Some(password) => archive
|
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"))?,
|
.map_err(|_| zip::result::ZipError::UnsupportedArchive("Password required to decrypt file"))?,
|
||||||
None => archive.by_index(idx)?,
|
None => archive.by_index(idx)?,
|
||||||
};
|
};
|
||||||
@ -127,8 +127,7 @@ where
|
|||||||
let maybe_file_in_archive = (|| {
|
let maybe_file_in_archive = (|| {
|
||||||
let zip_result = match password.clone() {
|
let zip_result = match password.clone() {
|
||||||
Some(password) => archive
|
Some(password) => archive
|
||||||
.by_index_decrypt(idx, password.to_owned().clone().as_bytes())
|
.by_index_decrypt(idx, password.as_bytes()).ok()?
|
||||||
.unwrap()
|
|
||||||
.map_err(|_| zip::result::ZipError::UnsupportedArchive("Password required to decrypt file")),
|
.map_err(|_| zip::result::ZipError::UnsupportedArchive("Password required to decrypt file")),
|
||||||
None => archive.by_index(idx),
|
None => archive.by_index(idx),
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user