Skip to content

Commit 19be12a

Browse files
authored
chore(cargo): upgrade async_zip to 0.0.17 (#6035)
1 parent 6a121b8 commit 19be12a

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

Cargo.lock

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async-channel = { workspace = true }
4444
async-imap = { version = "0.10.1", default-features = false, features = ["runtime-tokio"] }
4545
async-native-tls = { version = "0.5", default-features = false, features = ["runtime-tokio"] }
4646
async-smtp = { version = "0.9", default-features = false, features = ["runtime-tokio"] }
47-
async_zip = { version = "0.0.12", default-features = false, features = ["deflate", "fs"] }
47+
async_zip = { version = "0.0.17", default-features = false, features = ["deflate", "tokio-fs"] }
4848
base64 = { workspace = true }
4949
brotli = { version = "6", default-features=false, features = ["std"] }
5050
bytes = "1"

src/webxdc.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ use std::path::Path;
2323

2424
use anyhow::{anyhow, bail, ensure, format_err, Context as _, Result};
2525

26+
use async_zip::tokio::read::fs::ZipFileReader as FsZipFileReader;
2627
use deltachat_contact_tools::sanitize_bidi_characters;
2728
use deltachat_derive::FromSql;
2829
use lettre_email::PartBuilder;
2930
use rusqlite::OptionalExtension;
3031
use serde::{Deserialize, Serialize};
3132
use serde_json::Value;
32-
use tokio::io::AsyncReadExt;
3333

3434
use crate::chat::{self, Chat};
3535
use 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

803803
impl 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

Comments
 (0)