From 8f446d371bf17320b94444be2ee0ec87c943ad10 Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Tue, 16 Apr 2024 16:57:52 +0000 Subject: [PATCH] fix: oci cache store should fallback to copy when rename won't work --- 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| {