Skip to content

Commit dd125f1

Browse files
committed
chore(cargo): upgrade async_zip to 0.0.17
1 parent 6a121b8 commit dd125f1

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
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: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use lettre_email::PartBuilder;
2929
use rusqlite::OptionalExtension;
3030
use serde::{Deserialize, Serialize};
3131
use serde_json::Value;
32-
use tokio::io::AsyncReadExt;
3332

3433
use crate::chat::{self, Chat};
3534
use crate::constants::Chattype;
@@ -195,7 +194,7 @@ fn find_zip_entry<'a>(
195194
name: &str,
196195
) -> Option<(usize, &'a async_zip::StoredZipEntry)> {
197196
for (i, ent) in file.entries().iter().enumerate() {
198-
if ent.entry().filename() == name {
197+
if ent.filename().as_bytes() == name.as_bytes() {
199198
return Some((i, ent));
200199
}
201200
}
@@ -212,7 +211,7 @@ impl Context {
212211
return Ok(false);
213212
}
214213

215-
let archive = match async_zip::read::mem::ZipFileReader::new(file.to_vec()).await {
214+
let archive = match async_zip::base::read::mem::ZipFileReader::new(file.to_vec()).await {
216215
Ok(archive) => archive,
217216
Err(_) => {
218217
info!(self, "{} cannot be opened as zip-file", &filename);
@@ -235,7 +234,7 @@ impl Context {
235234
bail!("{} is not a valid webxdc file", filename);
236235
}
237236

238-
let valid = match async_zip::read::fs::ZipFileReader::new(path).await {
237+
let valid = match async_zip::tokio::read::fs::ZipFileReader::new(path).await {
239238
Ok(archive) => {
240239
if find_zip_entry(archive.file(), "index.html").is_none() {
241240
warn!(self, "{} misses index.html", filename);
@@ -791,12 +790,15 @@ fn parse_webxdc_manifest(bytes: &[u8]) -> Result<WebxdcManifest> {
791790
Ok(manifest)
792791
}
793792

794-
async fn get_blob(archive: &async_zip::read::fs::ZipFileReader, name: &str) -> Result<Vec<u8>> {
793+
async fn get_blob(
794+
archive: &async_zip::tokio::read::fs::ZipFileReader,
795+
name: &str,
796+
) -> Result<Vec<u8>> {
795797
let (i, _) = find_zip_entry(archive.file(), name)
796798
.ok_or_else(|| anyhow!("no entry found for {}", name))?;
797-
let mut reader = archive.entry(i).await?;
799+
let mut reader = archive.reader_with_entry(i).await?;
798800
let mut buf = Vec::new();
799-
reader.read_to_end(&mut buf).await?;
801+
reader.read_to_end_checked(&mut buf).await?;
800802
Ok(buf)
801803
}
802804

@@ -806,12 +808,12 @@ impl Message {
806808
async fn get_webxdc_archive(
807809
&self,
808810
context: &Context,
809-
) -> Result<async_zip::read::fs::ZipFileReader> {
811+
) -> Result<async_zip::tokio::read::fs::ZipFileReader> {
810812
let path = self
811813
.get_file(context)
812814
.ok_or_else(|| format_err!("No webxdc instance file."))?;
813815
let path_abs = get_abs_path(context, &path);
814-
let archive = async_zip::read::fs::ZipFileReader::new(path_abs).await?;
816+
let archive = async_zip::tokio::read::fs::ZipFileReader::new(path_abs).await?;
815817
Ok(archive)
816818
}
817819

0 commit comments

Comments
 (0)