From 4e9738b9597f9f82e2daafa773e7f4e5157ce040 Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Tue, 16 Apr 2024 10:05:24 -0700 Subject: [PATCH] fix: oci cache store should fallback to copy when rename won't work (#96) --- crates/oci/src/packer/cache.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/oci/src/packer/cache.rs b/crates/oci/src/packer/cache.rs index 0155659..32743c1 100644 --- a/crates/oci/src/packer/cache.rs +++ b/crates/oci/src/packer/cache.rs @@ -123,7 +123,10 @@ impl OciPackerCache { fs_path.push(format!("{}.{}", packed.digest, packed.format.extension())); manifest_path.push(format!("{}.manifest.json", packed.digest)); config_path.push(format!("{}.config.json", packed.digest)); - fs::rename(&packed.path, &fs_path).await?; + if fs::rename(&packed.path, &fs_path).await.is_err() { + fs::copy(&packed.path, &fs_path).await?; + fs::remove_file(&packed.path).await?; + } fs::write(&config_path, packed.config.raw()).await?; fs::write(&manifest_path, packed.manifest.raw()).await?; manifests.retain(|item| {