diff --git a/src/read.rs b/src/read.rs index f89bd311..f2a927c6 100644 --- a/src/read.rs +++ b/src/read.rs @@ -396,14 +396,11 @@ impl ZipArchive { } let data = &mut self.files[file_number]; - if password == None { - if data.encrypted { - return Err(ZipError::PasswordRequired); - } - } else if !data.encrypted { - //Password supplied, but none needed! Discard. - password = None; - } + match (password, data.encrypted) { + (None, true) => return Err(ZipError::PasswordRequired), + (Some(_), false) => password = None, //Password supplied, but none needed! Discard. + _ => {} + } // Parse local header self.reader.seek(io::SeekFrom::Start(data.header_start))?;