get_rootfile() simplified

This commit is contained in:
Martin Brodbeck 2024-11-12 10:37:01 +01:00
parent 8b38cee7b8
commit da77983228
2 changed files with 11 additions and 12 deletions

View file

@ -61,18 +61,17 @@ fn get_rootfile(archive: &mut ZipArchive<File>) -> String {
loop {
match reader.read_event_into(&mut buf) {
Ok(Event::Start(ref e)) | Ok(Event::Empty(ref e))
if e.local_name().into_inner() == b"rootfile" =>
if e.name().as_ref() == b"rootfile" =>
{
opf_filename = String::from_utf8(
e.attributes()
.filter(|attr| attr.as_ref().unwrap().key.into_inner() == b"full-path")
.next()
.unwrap()
.unwrap()
.value
.to_vec(),
)
.unwrap();
opf_filename = e
.attributes()
.filter(|attr| attr.as_ref().unwrap().key.as_ref() == b"full-path")
.next()
.unwrap()
.unwrap()
.unescape_value()
.unwrap()
.to_string();
break;
}
Ok(Event::Eof) => break,