From fce090c1de543f0bcebf47cfc2a32f99f8ef401f Mon Sep 17 00:00:00 2001
From: Alexander Strizhakov <alex.strizhakov@gmail.com>
Date: Wed, 11 Mar 2020 17:22:50 +0300
Subject: [PATCH] using Pleroma.Config instead of ets

---
 lib/pleroma/application.ex   |  2 +-
 lib/pleroma/config/holder.ex | 19 +++++++------------
 2 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex
index c5b9a98fd..33f1705df 100644
--- a/lib/pleroma/application.ex
+++ b/lib/pleroma/application.ex
@@ -31,7 +31,7 @@ def user_agent do
   # See http://elixir-lang.org/docs/stable/elixir/Application.html
   # for more information on OTP Applications
   def start(_type, _args) do
-    Pleroma.Config.Holder.to_ets()
+    Pleroma.Config.Holder.save_default()
     Pleroma.HTML.compile_scrubbers()
     Pleroma.Config.DeprecationWarnings.warn()
     Pleroma.Plugs.HTTPSecurityPlug.warn_if_disabled()
diff --git a/lib/pleroma/config/holder.ex b/lib/pleroma/config/holder.ex
index 88e1db313..f037d5d48 100644
--- a/lib/pleroma/config/holder.ex
+++ b/lib/pleroma/config/holder.ex
@@ -5,10 +5,8 @@
 defmodule Pleroma.Config.Holder do
   @config Pleroma.Config.Loader.default_config()
 
-  @spec to_ets() :: true
-  def to_ets do
-    :ets.new(:default_config, [:named_table, :protected])
-
+  @spec save_default() :: :ok
+  def save_default do
     default_config =
       if System.get_env("RELEASE_NAME") do
         release_config =
@@ -21,20 +19,17 @@ def to_ets do
         @config
       end
 
-    :ets.insert(:default_config, {:config, default_config})
+    Pleroma.Config.put(:default_config, default_config)
   end
 
   @spec default_config() :: keyword()
-  def default_config, do: from_ets()
+  def default_config, do: get_default()
 
   @spec default_config(atom()) :: keyword()
-  def default_config(group), do: Keyword.get(from_ets(), group)
+  def default_config(group), do: Keyword.get(get_default(), group)
 
   @spec default_config(atom(), atom()) :: keyword()
-  def default_config(group, key), do: get_in(from_ets(), [group, key])
+  def default_config(group, key), do: get_in(get_default(), [group, key])
 
-  defp from_ets do
-    [{:config, default_config}] = :ets.lookup(:default_config, :config)
-    default_config
-  end
+  defp get_default, do: Pleroma.Config.get(:default_config)
 end