summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Felder <feld@FreeBSD.org>2020-12-04 11:30:48 -0600
committerMark Felder <feld@FreeBSD.org>2020-12-04 11:30:48 -0600
commit3bf5c5b0156e1357db22df8e377c5cd5c5c8ea5a (patch)
tree58e1cf61a9f905e0c20f2fe6a908a617fc66d764
parent696d39c3dc32da1e3e163abb413f42d68c3a731f (diff)
Ensure deleting entire group prints out settings that will be removed before actually removing them
-rw-r--r--lib/mix/tasks/pleroma/config.ex38
1 files changed, 22 insertions, 16 deletions
diff --git a/lib/mix/tasks/pleroma/config.ex b/lib/mix/tasks/pleroma/config.ex
index 00e7be6f4..99dfd0dc3 100644
--- a/lib/mix/tasks/pleroma/config.ex
+++ b/lib/mix/tasks/pleroma/config.ex
@@ -142,7 +142,13 @@ defmodule Mix.Tasks.Pleroma.Config do
group = maybe_atomize(group)
- delete_group(group)
+ with true <- group_exists?(group) do
+ shell_info("The following settings will be removed from ConfigDB:\n")
+ dump_group(group)
+ delete_group(group)
+ else
+ _ -> shell_error("No settings in ConfigDB for #{inspect(group)}. Aborting.")
+ end
end
def run(["delete", group, key]) do
@@ -163,10 +169,17 @@ defmodule Mix.Tasks.Pleroma.Config do
group = maybe_atomize(group)
- if shell_prompt("Are you sure you want to continue?", "n") in ~w(Yn Y y) do
- delete_group(group)
+ with true <- group_exists?(group) do
+ shell_info("The following settings will be removed from ConfigDB:\n")
+ dump_group(group)
+
+ if shell_prompt("Are you sure you want to continue?", "n") in ~w(Yn Y y) do
+ delete_group(group)
+ else
+ shell_error("No changes made.")
+ end
else
- shell_error("No changes made.")
+ _ -> shell_error("No settings in ConfigDB for #{inspect(group)}. Aborting.")
end
end
@@ -329,18 +342,11 @@ defmodule Mix.Tasks.Pleroma.Config do
defp delete_group(group) do
check_configdb(fn ->
- with true <- group_exists?(group) do
- shell_info("The following settings will be removed from ConfigDB:\n")
- dump_group(group)
-
- group
- |> Pleroma.ConfigDB.get_all_by_group()
- |> Enum.each(fn config ->
- Pleroma.ConfigDB.delete(%{group: config.group, key: config.key})
- end)
- else
- _ -> shell_error("No settings in ConfigDB for #{inspect(group)}. Aborting.")
- end
+ group
+ |> Pleroma.ConfigDB.get_all_by_group()
+ |> Enum.each(fn config ->
+ Pleroma.ConfigDB.delete(%{group: config.group, key: config.key})
+ end)
end)
end