projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'chore/fast_sanitize_bump' into 'develop'
[akkoma]
/
lib
/
mix
/
tasks
/
pleroma
/
config.ex
diff --git
a/lib/mix/tasks/pleroma/config.ex
b/lib/mix/tasks/pleroma/config.ex
index a71bcd447bb648a4e9b9649273811910f4a1459e..590c7a91431ee271daa10007997b17e97b7a7201 100644
(file)
--- a/
lib/mix/tasks/pleroma/config.ex
+++ b/
lib/mix/tasks/pleroma/config.ex
@@
-8,18
+8,7
@@
defmodule Mix.Tasks.Pleroma.Config do
alias Pleroma.Repo
alias Pleroma.Web.AdminAPI.Config
@shortdoc "Manages the location of the config"
alias Pleroma.Repo
alias Pleroma.Web.AdminAPI.Config
@shortdoc "Manages the location of the config"
- @moduledoc """
- Manages the location of the config.
-
- ## Transfers config from file to DB.
-
- mix pleroma.config migrate_to_db
-
- ## Transfers config from DB to file.
-
- mix pleroma.config migrate_from_db ENV
- """
-
+ @moduledoc File.read!("docs/administration/CLI_tasks/config.md")
def run(["migrate_to_db"]) do
start_pleroma()
def run(["migrate_to_db"]) do
start_pleroma()
@@
-28,6
+17,14
@@
defmodule Mix.Tasks.Pleroma.Config do
|> Enum.reject(fn {k, _v} -> k in [Pleroma.Repo, :env] end)
|> Enum.each(fn {k, v} ->
key = to_string(k) |> String.replace("Elixir.", "")
|> Enum.reject(fn {k, _v} -> k in [Pleroma.Repo, :env] end)
|> Enum.each(fn {k, v} ->
key = to_string(k) |> String.replace("Elixir.", "")
+
+ key =
+ if String.starts_with?(key, "Pleroma.") do
+ key
+ else
+ ":" <> key
+ end
+
{:ok, _} = Config.update_or_create(%{group: "pleroma", key: key, value: v})
Mix.shell().info("#{key} is migrated.")
end)
{:ok, _} = Config.update_or_create(%{group: "pleroma", key: key, value: v})
Mix.shell().info("#{key} is migrated.")
end)
@@
-48,22
+45,16
@@
defmodule Mix.Tasks.Pleroma.Config do
if Pleroma.Config.get([:instance, :dynamic_configuration]) do
config_path = "config/#{env}.exported_from_db.secret.exs"
if Pleroma.Config.get([:instance, :dynamic_configuration]) do
config_path = "config/#{env}.exported_from_db.secret.exs"
- {:ok, file} = File.open(config_path, [:write])
+ {:ok, file} = File.open(config_path, [:write
, :utf8
])
IO.write(file, "use Mix.Config\r\n")
Repo.all(Config)
|> Enum.each(fn config ->
IO.write(file, "use Mix.Config\r\n")
Repo.all(Config)
|> Enum.each(fn config ->
- mark =
- if String.starts_with?(config.key, "Pleroma.") or
- String.starts_with?(config.key, "Ueberauth"),
- do: ",",
- else: ":"
-
IO.write(
file,
IO.write(
file,
- "config :#{config.group}, #{config.key}
#{mark}
#{
- inspect(Config.from_binary(config.value))
- }\r\n"
+ "config :#{config.group}, #{config.key}
,
#{
+ inspect(Config.from_binary(config.value)
, limit: :infinity
)
+ }\r\n
\r\n
"
)
if delete? do
)
if delete? do