diff --git a/Cargo.lock b/Cargo.lock index 7a6b17e..62b5d68 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2343,7 +2343,7 @@ dependencies = [ [[package]] name = "pixi-pack" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "async-std", diff --git a/Cargo.toml b/Cargo.toml index 4358e21..11ca1ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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] diff --git a/examples/no-timestamp/pixi.lock b/examples/no-timestamp/pixi.lock new file mode 100644 index 0000000..a793aad --- /dev/null +++ b/examples/no-timestamp/pixi.lock @@ -0,0 +1,21 @@ +version: 5 +environments: + default: + channels: + - url: https://conda.anaconda.org/conda-forge/ + packages: + osx-64: + - conda: https://conda.anaconda.org/conda-forge/osx-64/mpi-1.0-openmpi.tar.bz2 +packages: +- kind: conda + name: mpi + version: '1.0' + build: openmpi + subdir: osx-64 + url: https://conda.anaconda.org/conda-forge/osx-64/mpi-1.0-openmpi.tar.bz2 + sha256: 1326b28195e8808cebc18a593f84c5cbd606826a150dd7e0365f11b86238b5df + md5: 8c3bc725bf4d10fc6e56031f7543771f + arch: x86_64 + platform: osx + license: BSD 3-clause + size: 4394 diff --git a/examples/no-timestamp/pixi.toml b/examples/no-timestamp/pixi.toml new file mode 100644 index 0000000..85f016f --- /dev/null +++ b/examples/no-timestamp/pixi.toml @@ -0,0 +1,7 @@ +[project] +channels = ["conda-forge"] +name = "no-timestamp" +platforms = ["osx-64"] + +[dependencies] +mpi = { version = "1.0", build = "openmpi" } diff --git a/src/pack.rs b/src/pack.rs index a2d9d01..00a2e9e 100644 --- a/src/pack.rs +++ b/src/pack.rs @@ -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?; diff --git a/tests/integration_test.rs b/tests/integration_test.rs index efd4b8c..d77ec31 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -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) {