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 68f29ab
Showing 1 changed file with 14 additions and 2 deletions.
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 68f29ab

Please sign in to comment.