From 608f2e32aec5e6d03b41e39116f4a490c96db437 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 17 May 2023 14:33:30 +0000 Subject: [PATCH 1/2] Bump version to 7.2.6 --- app/mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/mix.exs b/app/mix.exs index 22e17a16e..8631f5c98 100644 --- a/app/mix.exs +++ b/app/mix.exs @@ -3,7 +3,7 @@ Code.require_file("lib/env.ex") defmodule Meadow.MixProject do use Mix.Project - @app_version "7.2.5" + @app_version "7.2.6" def project do [ From 6352e4625bac8d4c67b16c201fa01065314d753f Mon Sep 17 00:00:00 2001 From: "Michael B. Klein" Date: Wed, 17 May 2023 16:37:14 +0000 Subject: [PATCH 2/2] Avoid atom/string key collision when updating exif metadata --- .../pipeline/actions/extract_exif_metadata.ex | 2 +- .../actions/extract_exif_metadata_test.exs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/lib/meadow/pipeline/actions/extract_exif_metadata.ex b/app/lib/meadow/pipeline/actions/extract_exif_metadata.ex index 05e7a6a33..d6b86d0f5 100644 --- a/app/lib/meadow/pipeline/actions/extract_exif_metadata.ex +++ b/app/lib/meadow/pipeline/actions/extract_exif_metadata.ex @@ -55,7 +55,7 @@ defmodule Meadow.Pipeline.Actions.ExtractExifMetadata do extracted_metadata = case file_set.extracted_metadata do nil -> %{exif: exif_metadata} - map -> Map.put(map, :exif, exif_metadata) + map -> map |> Map.delete("exif") |> Map.put(:exif, exif_metadata) end FileSets.update_file_set(file_set, %{extracted_metadata: extracted_metadata}) diff --git a/app/test/pipeline/actions/extract_exif_metadata_test.exs b/app/test/pipeline/actions/extract_exif_metadata_test.exs index 50696a4d1..9a20214d2 100644 --- a/app/test/pipeline/actions/extract_exif_metadata_test.exs +++ b/app/test/pipeline/actions/extract_exif_metadata_test.exs @@ -215,5 +215,24 @@ defmodule Meadow.Pipeline.Actions.ExtractExifMetadataTest do assert log =~ ~r/already complete without overwriting/ end + + test "key collision", %{exif_file_set_id: file_set_id} do + with file_set <- FileSets.get_file_set!(file_set_id) do + extracted_metadata = put_in(file_set.extracted_metadata, ["exif", "value"], "bogus") + FileSets.update_file_set(file_set, %{extracted_metadata: extracted_metadata}) + end + + with %{extracted_metadata: subject} <- FileSets.get_file_set!(file_set_id) do + assert get_in(subject, ["exif", "value"]) == "bogus" + end + + assert {:ok, %{id: ^file_set_id}, %{}} = + send_test_message(ExtractExifMetadata, %{file_set_id: file_set_id}, %{}) + + FileSets.get_file_set!(file_set_id) + |> Map.get(:extracted_metadata) + |> get_in(["exif", "value"]) + |> assert_maps_equal(@exif, @keys) + end end end