fix: oci cache store should fallback to copy when rename won't work (#96)

This commit is contained in:
Alex Zenla 2024-04-16 10:05:24 -07:00 committed by GitHub
parent 8135307283
commit 4e9738b959
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -123,7 +123,10 @@ impl OciPackerCache {
fs_path.push(format!("{}.{}", packed.digest, packed.format.extension())); fs_path.push(format!("{}.{}", packed.digest, packed.format.extension()));
manifest_path.push(format!("{}.manifest.json", packed.digest)); manifest_path.push(format!("{}.manifest.json", packed.digest));
config_path.push(format!("{}.config.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(&config_path, packed.config.raw()).await?;
fs::write(&manifest_path, packed.manifest.raw()).await?; fs::write(&manifest_path, packed.manifest.raw()).await?;
manifests.retain(|item| { manifests.retain(|item| {