From c58dea76f699a0786bc05feb353f0dcc9523c97b Mon Sep 17 00:00:00 2001 From: John Ayad Date: Tue, 1 Aug 2023 15:26:23 +0100 Subject: [PATCH 1/2] Fix: Generate valid tar archives --- crates/rattler_package_streaming/src/write.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/rattler_package_streaming/src/write.rs b/crates/rattler_package_streaming/src/write.rs index ecb516f22..76a1e7d47 100644 --- a/crates/rattler_package_streaming/src/write.rs +++ b/crates/rattler_package_streaming/src/write.rs @@ -6,6 +6,7 @@ use std::path::{Path, PathBuf}; use itertools::sorted; use rattler_conda_types::package::PackageMetadata; +use tar::EntryType; /// a function that sorts paths into two iterators, one that starts with `info/` and one that does not /// both iterators are sorted alphabetically for reproducibility @@ -238,7 +239,7 @@ fn prepare_header( header.set_device_major(0)?; if let Some(timestamp) = timestamp { - header.set_mtime(timestamp.timestamp() as u64); + header.set_mtime(timestamp.timestamp().unsigned_abs()); } // let file_size = stat.len(); @@ -264,10 +265,10 @@ fn append_path_to_archive( .map_err(|err| trace_file_error(&base_path.join(path), err))?; if header.entry_type().is_file() { - let file = fs::File::open(base_path.join(path)) + let mut file = fs::File::open(base_path.join(path)) .map_err(|err| trace_file_error(&base_path.join(path), err))?; - archive.append_data(&mut header, path, file)?; + archive.append_file(path, &mut file)?; } else if header.entry_type().is_symlink() || header.entry_type().is_hard_link() { let target = fs::read_link(base_path.join(path)) .map_err(|err| trace_file_error(&base_path.join(path), err))?; From 2a7802735e5cf6159f7d38eb17a43a41ce5882e5 Mon Sep 17 00:00:00 2001 From: John Ayad Date: Tue, 1 Aug 2023 15:35:24 +0100 Subject: [PATCH 2/2] unused --- crates/rattler_package_streaming/src/write.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/rattler_package_streaming/src/write.rs b/crates/rattler_package_streaming/src/write.rs index 76a1e7d47..3c08f1bc3 100644 --- a/crates/rattler_package_streaming/src/write.rs +++ b/crates/rattler_package_streaming/src/write.rs @@ -6,7 +6,6 @@ use std::path::{Path, PathBuf}; use itertools::sorted; use rattler_conda_types::package::PackageMetadata; -use tar::EntryType; /// a function that sorts paths into two iterators, one that starts with `info/` and one that does not /// both iterators are sorted alphabetically for reproducibility