Skip to content

Commit

Permalink
fix(bucket_storage): image deletion
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
noaccOS committed Dec 9, 2024
1 parent 1537d42 commit 171b105
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

## [0.9.2] - 2024-12-09
### Changed
- Update the docker-compose configuration to allow both physical and virtual devices
Expand Down
16 changes: 14 additions & 2 deletions backend/lib/edgehog/base_images/bucket_storage.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 171b105

Please sign in to comment.