Skip to content

Commit

Permalink
uv-extract: call target.as_ref() once
Browse files Browse the repository at this point in the history
This is just a style thing.
  • Loading branch information
BurntSushi committed Feb 20, 2024
1 parent 634d593 commit d6aaf7b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/uv-extract/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub async fn unzip<R: tokio::io::AsyncRead + Unpin>(
reader: R,
target: impl AsRef<Path>,
) -> Result<(), Error> {
let target = target.as_ref();
let mut reader = reader.compat();
let mut zip = async_zip::base::read::stream::ZipFileReader::new(&mut reader);

Expand All @@ -22,7 +23,7 @@ pub async fn unzip<R: tokio::io::AsyncRead + Unpin>(
while let Some(mut entry) = zip.next_with_entry().await? {
// Construct the (expected) path to the file on-disk.
let path = entry.reader().entry().filename().as_str()?;
let path = target.as_ref().join(path);
let path = target.join(path);
let is_dir = entry.reader().entry().dir()?;

// Either create the directory or write the file to disk.
Expand Down Expand Up @@ -81,7 +82,7 @@ pub async fn unzip<R: tokio::io::AsyncRead + Unpin>(
if has_any_executable_bit != 0 {
// Construct the (expected) path to the file on-disk.
let path = entry.filename().as_str()?;
let path = target.as_ref().join(path);
let path = target.join(path);

let permissions = fs_err::tokio::metadata(&path).await?.permissions();
fs_err::tokio::set_permissions(
Expand Down

0 comments on commit d6aaf7b

Please sign in to comment.