Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set last modified for zip archive #649

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions crates/rattler_package_streaming/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use std::fs::{self, File};
use std::io::{self, Read, Seek, Write};
use std::path::{Path, PathBuf};

use chrono::{Datelike, Timelike};
use rattler_conda_types::package::PackageMetadata;
use zip::DateTime;

/// Trait for progress bars
pub trait ProgressBar {
Expand Down Expand Up @@ -289,8 +291,26 @@ pub fn write_conda_package<W: Write + Seek>(
) -> Result<(), std::io::Error> {
// first create the outer zip archive that uses no compression
let mut outer_archive = zip::ZipWriter::new(writer);
let options =
zip::write::FileOptions::default().compression_method(zip::CompressionMethod::Stored);

let last_modified_time = if let Some(time) = timestamp {
DateTime::from_date_and_time(
time.year() as u16,
time.month() as u8,
time.day() as u8,
time.hour() as u8,
time.minute() as u8,
time.second() as u8,
)
.expect("time should be in correct range")
} else {
// 1-1-2023 00:00:00 (Fixed date in the past for reproducible builds)
DateTime::from_date_and_time(2023, 1, 1, 0, 0, 0)
.expect("1-1-2023 00:00:00 should convert into datetime")
};

let options = zip::write::FileOptions::default()
.compression_method(zip::CompressionMethod::Stored)
.last_modified_time(last_modified_time);

// write the metadata as first file in the zip archive
let package_metadata = PackageMetadata::default();
Expand Down
Loading