From 178a825f94ef3323a6e601faf29eeec76de0bbaa Mon Sep 17 00:00:00 2001 From: Francesco Noacco Date: Wed, 9 Oct 2024 11:02:10 +0200 Subject: [PATCH] fix(bucket_storage): image deletion previously, calling Ash.destroy! on a base image would crash the program because Edgehog.BaseImages.Uploaders.BaseImage.filename/2 would try to access the field `base_image_version` of a BaseImage, which does not exist Signed-off-by: Francesco Noacco --- CHANGELOG.md | 4 ++++ .../lib/edgehog/base_images/bucket_storage.ex | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7273c1d7d..9d983f3e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.9.3] - Unreleased +### Fixed +- Base Image deletion in S3 storage + ## [0.9.2] - 2024-12-09 ### Changed - Update the docker-compose configuration to allow both physical and virtual devices diff --git a/backend/lib/edgehog/base_images/bucket_storage.ex b/backend/lib/edgehog/base_images/bucket_storage.ex index 3ce0490d5..94a261bae 100644 --- a/backend/lib/edgehog/base_images/bucket_storage.ex +++ b/backend/lib/edgehog/base_images/bucket_storage.ex @@ -42,8 +42,20 @@ defmodule Edgehog.BaseImages.BucketStorage do end @impl Storage - def delete(%BaseImage{} = scope) do - %BaseImage{url: url} = scope + def delete(%BaseImage{} = base_image) do + %BaseImage{ + url: url, + tenant_id: tenant_id, + version: base_image_version, + base_image_collection_id: base_image_collection_id + } = base_image + + scope = %{ + tenant_id: tenant_id, + base_image_collection_id: base_image_collection_id, + base_image_version: base_image_version + } + Uploaders.BaseImage.delete({url, scope}) end end