From edffd23802620f12b7e20ba4e59d9a24e825255e Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Wed, 26 Jun 2024 21:50:10 -0500 Subject: [PATCH] Have cache actually check cache Cache has not been hitting the actual cache bits, so now we will tell it to reach out to the cache server locally and check for the ISO to be present in the bucket before we run the curl at all --- nix/cache.nix | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/nix/cache.nix b/nix/cache.nix index 33ea53f..5db075d 100644 --- a/nix/cache.nix +++ b/nix/cache.nix @@ -19,23 +19,18 @@ in writeShellApplication { minio-client packer ]; - text = (concatStringsSep "\n" ( + text = '' + mc alias set storage "$STORAGE_URL" root "$MINIO_SECRET" + '' + (concatStringsSep "\n" ( map (d: '' url=$(echo var.iso.url | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/) sha=$(echo var.iso.checksum | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/) - if [ ! -e "cache/$sha.iso" ]; then + if [ -z "$(mc ls storage/isos/cache/ | grep $sha)" ]; then curl --retry 3 --retry-all-errors -o "cache/$sha.iso" "$url" + mc put "cache/$sha.iso" "storage/isos/cache/$sha.iso" else echo "Skipping ${d.distro} - cache/$sha.iso" fi '') active - )) + '' - ls -lh cache/ - - mc alias set storage "$STORAGE_URL" root "$MINIO_SECRET" - - for f in cache/*; do - mc put "$f" "storage/isos/$f" - done - ''; + )); }