Skip to content

Commit

Permalink
fix: Use default timestamp when no timestamp is provided in package
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzw committed Oct 25, 2024
1 parent 5a7b59b commit 2985c71
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "pixi-pack"
description = "A command line tool to pack and unpack conda environments for easy sharing"
version = "0.2.1"
version = "0.2.2"
edition = "2021"

[features]
Expand Down
21 changes: 21 additions & 0 deletions examples/no-timestamp/pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions examples/no-timestamp/pixi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[project]
channels = ["conda-forge"]
name = "no-timestamp"
platforms = ["osx-64"]

[dependencies]
mpi = { version = "1.0", build = "openmpi" }
11 changes: 8 additions & 3 deletions src/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,15 @@ async fn download_package(
let package_timestamp = package
.package_record()
.timestamp
.ok_or_else(|| anyhow!("could not read package timestamp"))?;
.map_or({
tracing::error!("could not get timestamp of {:?}, using default", package.file_name());
std::time::SystemTime::UNIX_EPOCH
}, |ts| {
ts.into()
});
let file_times = FileTimes::new()
.set_modified(package_timestamp.into())
.set_accessed(package_timestamp.into());
.set_modified(package_timestamp)
.set_accessed(package_timestamp);

// Make sure to write all data and metadata to disk before modifying timestamp.
dest.sync_all().await?;
Expand Down
11 changes: 11 additions & 0 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,17 @@ async fn test_non_authenticated(
.contains("failed to download"));
}

#[rstest]
#[tokio::test]
async fn test_no_timestamp(
#[with(PathBuf::from("examples/no-timestamp/pixi.toml"))] options: Options,
) {
let mut pack_options = options.pack_options;
pack_options.platform = Platform::Osx64;
let pack_result = pixi_pack::pack(pack_options).await;
assert!(pack_result.is_ok());
}

#[rstest]
#[tokio::test]
async fn test_custom_env_name(options: Options) {
Expand Down

0 comments on commit 2985c71

Please sign in to comment.