Skip to content

Commit c5eaf84

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

File tree

5 files changed

+46
-23
lines changed

5 files changed

+46
-23
lines changed

Cargo.lock

Lines changed: 18 additions & 18 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
@@ -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

Lines changed: 1 addition & 1 deletion
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/stream.rs

Lines changed: 25 additions & 2 deletions
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,17 @@ 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 (they will be created if needed by
154+
// descendants), to ensure that directory permissions do not interfere with descendant
155+
// extraction.
156+
let mut directories = Vec::new();
157+
146158
let mut entries = archive.entries()?;
147159
let mut pinned = Pin::new(&mut entries);
148160
while let Some(entry) = pinned.next().await {
@@ -159,7 +171,12 @@ async fn untar_in(
159171
continue;
160172
}
161173

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

164181
// Preserve the executable bit.
165182
#[cfg(unix)]
@@ -172,7 +189,7 @@ async fn untar_in(
172189
let mode = file.header().mode()?;
173190
let has_any_executable_bit = mode & 0o111;
174191
if has_any_executable_bit != 0 {
175-
if let Some(path) = crate::tar::unpacked_at(dst, &file.path()?) {
192+
if let Some(path) = crate::tar::unpacked_at(&dst, &file.path()?) {
176193
let permissions = fs_err::tokio::metadata(&path).await?.permissions();
177194
if permissions.mode() & 0o111 != 0o111 {
178195
fs_err::tokio::set_permissions(
@@ -186,6 +203,12 @@ async fn untar_in(
186203
}
187204
}
188205
}
206+
207+
// Create any deferred directories.
208+
for mut dir in directories {
209+
dir.unpack_in_memo(&dst, &mut memo).await?;
210+
}
211+
189212
Ok(())
190213
}
191214

crates/uv-publish/Cargo.toml

Lines changed: 1 addition & 1 deletion
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)