From 8023fa48dbc68fe696337a4da940b95fd209e304 Mon Sep 17 00:00:00 2001 From: Alexander Strizhakov Date: Mon, 20 Jan 2020 18:25:00 +0300 Subject: [PATCH] merge fix --- lib/pleroma/config/config_db.ex | 20 +++++++++++++++++++- lib/pleroma/web/admin_api/admin_api_controller.ex | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/config/config_db.ex b/lib/pleroma/config/config_db.ex index 85a049f8a..0091f7a1b 100644 --- a/lib/pleroma/config/config_db.ex +++ b/lib/pleroma/config/config_db.ex @@ -102,7 +102,7 @@ defmodule Pleroma.ConfigDB do subkeys = sub_key_full_update(group, key, intersect_keys) - merged_value = DeepMerge.deep_merge(old_value, new_value) + merged_value = ConfigDB.merge(old_value, new_value) Enum.reduce(subkeys, merged_value, fn subkey, acc -> Keyword.put(acc, subkey, new_value[subkey]) @@ -127,6 +127,24 @@ defmodule Pleroma.ConfigDB do |> List.flatten() end + def merge(config1, config2) when is_list(config1) and is_list(config2) do + Keyword.merge(config1, config2, fn _, app1, app2 -> + if Keyword.keyword?(app1) and Keyword.keyword?(app2) do + Keyword.merge(app1, app2, &deep_merge/3) + else + app2 + end + end) + end + + defp deep_merge(_key, value1, value2) do + if Keyword.keyword?(value1) and Keyword.keyword?(value2) do + Keyword.merge(value1, value2, &deep_merge/3) + else + value2 + end + end + @full_key_update [ {:pleroma, :ecto_repos}, {:quack, :meta}, diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex index cc658dc0e..30343a9f1 100644 --- a/lib/pleroma/web/admin_api/admin_api_controller.ex +++ b/lib/pleroma/web/admin_api/admin_api_controller.ex @@ -826,7 +826,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do else merged = Pleroma.Config.Holder.config() - |> DeepMerge.deep_merge(configs) + |> ConfigDB.merge(configs) |> Enum.map(fn {group, values} -> Enum.map(values, fn {key, value} -> db =