Skip to content

Commit

Permalink
Run formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Majored committed Apr 1, 2024
1 parent 0bf0fd0 commit 365f424
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 12 deletions.
5 changes: 4 additions & 1 deletion examples/file_extraction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ use std::{
};

use async_zip::base::read::seek::ZipFileReader;
use tokio::{fs::{create_dir_all, File, OpenOptions}, io::BufReader};
use tokio::{
fs::{create_dir_all, File, OpenOptions},
io::BufReader,
};
use tokio_util::compat::{TokioAsyncReadCompatExt, TokioAsyncWriteCompatExt};

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion src/base/read/io/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::spec::Compression;
use std::pin::Pin;
use std::task::{Context, Poll};

use futures_lite::io::{AsyncRead, AsyncReadExt, Take, AsyncBufRead};
use futures_lite::io::{AsyncBufRead, AsyncRead, AsyncReadExt, Take};
use pin_project::pin_project;

/// A type which encodes that [`ZipEntryReader`] has associated entry data.
Expand Down
12 changes: 10 additions & 2 deletions src/base/read/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,21 @@ pub(crate) mod hashed;
pub(crate) mod locator;
pub(crate) mod owned;

use std::{future::Future, io::ErrorKind, pin::Pin, task::{ready, Context, Poll}};
use std::{
future::Future,
io::ErrorKind,
pin::Pin,
task::{ready, Context, Poll},
};

pub use combined_record::CombinedCentralDirectoryRecord;
use futures_lite::io::AsyncBufRead;
use pin_project::pin_project;

use crate::{spec::consts::{DATA_DESCRIPTOR_LENGTH, DATA_DESCRIPTOR_SIGNATURE, SIGNATURE_LENGTH}, string::{StringEncoding, ZipString}};
use crate::{
spec::consts::{DATA_DESCRIPTOR_LENGTH, DATA_DESCRIPTOR_SIGNATURE, SIGNATURE_LENGTH},
string::{StringEncoding, ZipString},
};
use futures_lite::io::{AsyncRead, AsyncReadExt};

/// Read and return a dynamic length string from a reader which impls AsyncRead.
Expand Down
2 changes: 1 addition & 1 deletion src/base/read/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ use crate::file::ZipFile;

use std::sync::Arc;

use futures_lite::io::{Cursor};
use futures_lite::io::Cursor;

use super::io::entry::{WithEntry, WithoutEntry};

Expand Down
2 changes: 1 addition & 1 deletion src/base/read/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ where

if header.flags.data_descriptor && compression == Compression::Stored {
return Err(ZipError::FeatureNotSupported(
"stream reading entries with data descriptors & Stored compression mode",
"stream reading entries with data descriptors & Stored compression mode",
));
}
if header.flags.encrypted {
Expand Down
13 changes: 8 additions & 5 deletions src/base/read/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ use crate::error::ZipError;
#[cfg(feature = "tokio")]
use crate::tokio::read::stream::Ready as TokioReady;

use futures_lite::io::AsyncReadExt;
use futures_lite::io::AsyncBufRead;
use futures_lite::io::AsyncReadExt;

#[cfg(feature = "tokio")]
use tokio_util::compat::TokioAsyncReadCompatExt;
Expand Down Expand Up @@ -92,7 +92,9 @@ where
None => return Ok(None),
};

let reader = ZipEntryReader::new_with_owned(self.0.0, entry.compression, u64::MAX);
let length = if entry.data_descriptor { u64::MAX } else { entry.compressed_size };
let reader = ZipEntryReader::new_with_owned(self.0 .0, entry.compression, length);

Ok(Some(ZipFileReader(Reading(reader, entry.data_descriptor))))
}

Expand All @@ -103,7 +105,8 @@ where
None => return Ok(None),
};

let reader = ZipEntryReader::new_with_owned(self.0.0, entry.compression, u64::MAX);
let length = if entry.data_descriptor { u64::MAX } else { entry.compressed_size };
let reader = ZipEntryReader::new_with_owned(self.0 .0, entry.compression, length);
let data_descriptor = entry.data_descriptor;

Ok(Some(ZipFileReader(Reading(reader.into_with_entry_owned(entry), data_descriptor))))
Expand Down Expand Up @@ -149,7 +152,7 @@ where
let mut inner = self.0 .0.into_inner();

// Has data descriptor.
if self.0.1 {
if self.0 .1 {
ConsumeDataDescriptor(&mut inner).await?;
}

Expand All @@ -162,7 +165,7 @@ where
let mut inner = self.0 .0.into_inner();

// Has data descriptor.
if self.0.1 {
if self.0 .1 {
ConsumeDataDescriptor(&mut inner).await?;
}

Expand Down
5 changes: 4 additions & 1 deletion src/tokio/read/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ impl ZipFileReader {
}

/// Returns a new entry reader if the provided index is valid.
pub async fn reader_with_entry(&self, index: usize) -> Result<ZipEntryReader<'_, Compat<BufReader<File>>, WithEntry<'_>>> {
pub async fn reader_with_entry(
&self,
index: usize,
) -> Result<ZipEntryReader<'_, Compat<BufReader<File>>, WithEntry<'_>>> {
let stored_entry = self.inner.file.entries.get(index).ok_or(ZipError::EntryIndexOutOfBounds)?;
let mut fs_file = BufReader::new(File::open(&self.inner.path).await?).compat();

Expand Down

0 comments on commit 365f424

Please sign in to comment.