@@ -23,13 +23,13 @@ use std::path::Path;
2323
2424use anyhow:: { anyhow, bail, ensure, format_err, Context as _, Result } ;
2525
26+ use async_zip:: tokio:: read:: fs:: ZipFileReader as FsZipFileReader ;
2627use deltachat_contact_tools:: sanitize_bidi_characters;
2728use deltachat_derive:: FromSql ;
2829use lettre_email:: PartBuilder ;
2930use rusqlite:: OptionalExtension ;
3031use serde:: { Deserialize , Serialize } ;
3132use serde_json:: Value ;
32- use tokio:: io:: AsyncReadExt ;
3333
3434use crate :: chat:: { self , Chat } ;
3535use crate :: constants:: Chattype ;
@@ -195,7 +195,7 @@ fn find_zip_entry<'a>(
195195 name : & str ,
196196) -> Option < ( usize , & ' a async_zip:: StoredZipEntry ) > {
197197 for ( i, ent) in file. entries ( ) . iter ( ) . enumerate ( ) {
198- if ent. entry ( ) . filename ( ) == name {
198+ if ent. filename ( ) . as_bytes ( ) == name. as_bytes ( ) {
199199 return Some ( ( i, ent) ) ;
200200 }
201201 }
@@ -212,7 +212,7 @@ impl Context {
212212 return Ok ( false ) ;
213213 }
214214
215- let archive = match async_zip:: read:: mem:: ZipFileReader :: new ( file. to_vec ( ) ) . await {
215+ let archive = match async_zip:: base :: read:: mem:: ZipFileReader :: new ( file. to_vec ( ) ) . await {
216216 Ok ( archive) => archive,
217217 Err ( _) => {
218218 info ! ( self , "{} cannot be opened as zip-file" , & filename) ;
@@ -235,7 +235,7 @@ impl Context {
235235 bail ! ( "{} is not a valid webxdc file" , filename) ;
236236 }
237237
238- let valid = match async_zip :: read :: fs :: ZipFileReader :: new ( path) . await {
238+ let valid = match FsZipFileReader :: new ( path) . await {
239239 Ok ( archive) => {
240240 if find_zip_entry ( archive. file ( ) , "index.html" ) . is_none ( ) {
241241 warn ! ( self , "{} misses index.html" , filename) ;
@@ -791,27 +791,24 @@ fn parse_webxdc_manifest(bytes: &[u8]) -> Result<WebxdcManifest> {
791791 Ok ( manifest)
792792}
793793
794- async fn get_blob ( archive : & async_zip :: read :: fs :: ZipFileReader , name : & str ) -> Result < Vec < u8 > > {
794+ async fn get_blob ( archive : & FsZipFileReader , name : & str ) -> Result < Vec < u8 > > {
795795 let ( i, _) = find_zip_entry ( archive. file ( ) , name)
796796 . ok_or_else ( || anyhow ! ( "no entry found for {}" , name) ) ?;
797- let mut reader = archive. entry ( i) . await ?;
797+ let mut reader = archive. reader_with_entry ( i) . await ?;
798798 let mut buf = Vec :: new ( ) ;
799- reader. read_to_end ( & mut buf) . await ?;
799+ reader. read_to_end_checked ( & mut buf) . await ?;
800800 Ok ( buf)
801801}
802802
803803impl Message {
804804 /// Get handle to a webxdc ZIP-archive.
805805 /// To check for file existence use archive.by_name(), to read a file, use get_blob(archive).
806- async fn get_webxdc_archive (
807- & self ,
808- context : & Context ,
809- ) -> Result < async_zip:: read:: fs:: ZipFileReader > {
806+ async fn get_webxdc_archive ( & self , context : & Context ) -> Result < FsZipFileReader > {
810807 let path = self
811808 . get_file ( context)
812809 . ok_or_else ( || format_err ! ( "No webxdc instance file." ) ) ?;
813810 let path_abs = get_abs_path ( context, & path) ;
814- let archive = async_zip :: read :: fs :: ZipFileReader :: new ( path_abs) . await ?;
811+ let archive = FsZipFileReader :: new ( path_abs) . await ?;
815812 Ok ( archive)
816813 }
817814
0 commit comments