Skip to content

Commit 6503023

Browse files
committed
oci: Switch to tar-core crate
Working on direct import from containers-storage: I hit on the fact that our tar parsing was very hand-rolled and incomplete. We didn't handle PAX overrides correctly, there was a big `todo!` for global headers where we'd panic, etc. Recently I did a new tar-core crate which is now part of the composefs org - it's "sans-io" so works cleanly with both sync and async parsing. Update the code to use it. The tar crate is retained as a dev-dependency for tar::Builder in tests. Assisted-by: OpenCode (Claude claude-opus-4-6) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 1b48236 commit 6503023

4 files changed

Lines changed: 394 additions & 217 deletions

File tree

crates/composefs-oci/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ rustix = { version = "1.0.0", features = ["fs"] }
2424
serde = { version = "1.0", default-features = false, features = ["derive"] }
2525
serde_json = { version = "1.0", default-features = false, features = ["std"] }
2626
sha2 = { version = "0.10.1", default-features = false }
27-
tar = { version = "0.4.38", default-features = false }
27+
tar-core = "0.1.0"
2828
tokio = { version = "1.24.2", features = ["rt-multi-thread"] }
2929
tokio-util = { version = "0.7", default-features = false, features = ["io"] }
3030

3131
[dev-dependencies]
3232
similar-asserts = "1.7.0"
33+
tar = { version = "0.4.38", default-features = false }
3334
composefs = { workspace = true, features = ["test"] }
3435
once_cell = "1.21.3"
3536
proptest = "1"

crates/composefs-oci/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub async fn import_layer<ObjectID: FsVerityHashValue>(
115115
repo: &Arc<Repository<ObjectID>>,
116116
diff_id: &str,
117117
name: Option<&str>,
118-
tar_stream: impl tokio::io::AsyncBufRead + Unpin,
118+
tar_stream: impl tokio::io::AsyncRead + Unpin,
119119
) -> Result<(ObjectID, ImportStats)> {
120120
let content_identifier = layer_identifier(diff_id);
121121

crates/composefs-oci/src/skopeo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl<ObjectID: FsVerityHashValue> ImageOp<ObjectID> {
196196
let media_type = descriptor.media_type();
197197
let (object_id, layer_stats) = if is_tar_media_type(media_type) {
198198
// Tar layers: decompress and split into a splitstream
199-
let reader: Box<dyn tokio::io::AsyncBufRead + Unpin + Send> = match media_type {
199+
let reader: Box<dyn tokio::io::AsyncRead + Unpin + Send> = match media_type {
200200
MediaType::ImageLayer | MediaType::ImageLayerNonDistributable => {
201201
Box::new(BufReader::with_capacity(IO_BUF_CAPACITY, progress))
202202
}

0 commit comments

Comments
 (0)