Skip to content

Commit 49fe355

Browse files
committed
Use Astral-maintained tokio-tar fork
1 parent 1cfe5be commit 49fe355

File tree

7 files changed

+45
-64
lines changed

7 files changed

+45
-64
lines changed

Cargo.lock

+18-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ uv-workspace = { path = "crates/uv-workspace" }
7373
anstream = { version = "0.6.15" }
7474
anyhow = { version = "1.0.89" }
7575
arcstr = { version = "1.2.0" }
76+
astral-tokio-tar = { git = "https://github.com/astral-sh/tokio-tar", branch = "charlie/memo" }
7677
async-channel = { version = "2.3.1" }
7778
async-compression = { version = "0.4.12", features = ["bzip2", "gzip", "xz", "zstd"] }
7879
async-trait = { version = "0.1.82" }
@@ -118,7 +119,6 @@ indoc = { version = "2.0.5" }
118119
itertools = { version = "0.14.0" }
119120
jiff = { version = "0.1.14", features = ["serde"] }
120121
junction = { version = "1.2.0" }
121-
krata-tokio-tar = { version = "0.4.2" }
122122
mailparse = { version = "0.15.0" }
123123
md-5 = { version = "0.10.6" }
124124
memchr = { version = "2.7.4" }

crates/uv-extract/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ uv-configuration = { workspace = true }
2020
uv-distribution-filename = { workspace = true }
2121
uv-pypi-types = { workspace = true }
2222

23+
astral-tokio-tar = { workspace = true }
2324
async-compression = { workspace = true, features = ["bzip2", "gzip", "zstd", "xz"] }
2425
async_zip = { workspace = true }
2526
fs-err = { workspace = true, features = ["tokio"] }
2627
futures = { workspace = true }
27-
krata-tokio-tar = { workspace = true }
2828
md-5 = { workspace = true }
2929
rayon = { workspace = true }
3030
reqwest = { workspace = true }

crates/uv-extract/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ mod error;
55
pub mod hash;
66
pub mod stream;
77
mod sync;
8-
mod tar;
98
mod vendor;

crates/uv-extract/src/stream.rs

+24-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::pin::Pin;
33

44
use futures::StreamExt;
55
use rustc_hash::FxHashSet;
6+
use tokio_tar::EntryType;
67
use tokio_util::compat::{FuturesAsyncReadCompatExt, TokioAsyncReadCompatExt};
78
use tracing::warn;
89

@@ -143,6 +144,16 @@ async fn untar_in(
143144
mut archive: tokio_tar::Archive<&'_ mut (dyn tokio::io::AsyncRead + Unpin)>,
144145
dst: &Path,
145146
) -> std::io::Result<()> {
147+
// Like `tokio-tar`, canonicalize the destination prior to unpacking.
148+
let dst = fs_err::tokio::canonicalize(dst).await?;
149+
150+
// Memoize filesystem calls to canonicalize paths.
151+
let mut memo = FxHashSet::default();
152+
153+
// Delay any directory entries until the end, to ensure that directory permissions do not
154+
// interfere with descendant extraction.
155+
let mut directories = Vec::new();
156+
146157
let mut entries = archive.entries()?;
147158
let mut pinned = Pin::new(&mut entries);
148159
while let Some(entry) = pinned.next().await {
@@ -159,7 +170,12 @@ async fn untar_in(
159170
continue;
160171
}
161172

162-
file.unpack_in(dst).await?;
173+
if file.header().entry_type() == EntryType::Directory {
174+
directories.push(file);
175+
continue;
176+
}
177+
178+
let unpacked_at = file.unpack_in_memo(&dst, &mut memo).await?;
163179

164180
// Preserve the executable bit.
165181
#[cfg(unix)]
@@ -172,7 +188,7 @@ async fn untar_in(
172188
let mode = file.header().mode()?;
173189
let has_any_executable_bit = mode & 0o111;
174190
if has_any_executable_bit != 0 {
175-
if let Some(path) = crate::tar::unpacked_at(dst, &file.path()?) {
191+
if let Some(path) = unpacked_at.as_deref() {
176192
let permissions = fs_err::tokio::metadata(&path).await?.permissions();
177193
if permissions.mode() & 0o111 != 0o111 {
178194
fs_err::tokio::set_permissions(
@@ -186,6 +202,12 @@ async fn untar_in(
186202
}
187203
}
188204
}
205+
206+
// Create any deferred directories.
207+
for mut dir in directories {
208+
dir.unpack_in_memo(&dst, &mut memo).await?;
209+
}
210+
189211
Ok(())
190212
}
191213

crates/uv-extract/src/tar.rs

-40
This file was deleted.

crates/uv-publish/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ uv-pypi-types = { workspace = true }
2525
uv-static = { workspace = true }
2626
uv-warnings = { workspace = true }
2727

28+
astral-tokio-tar = { workspace = true }
2829
async-compression = { workspace = true }
2930
base64 = { workspace = true }
3031
fs-err = { workspace = true }
3132
futures = { workspace = true }
3233
glob = { workspace = true }
3334
itertools = { workspace = true }
34-
krata-tokio-tar = { workspace = true }
3535
reqwest = { workspace = true }
3636
reqwest-middleware = { workspace = true }
3737
reqwest-retry = { workspace = true }

0 commit comments

Comments
 (0)