mix: instance: ensure all needed folders are created before generating config
authorAlibek Omarov <a1ba.omarov@gmail.com>
Thu, 28 Jan 2021 09:39:53 +0000 (09:39 +0000)
committerAlibek Omarov <a1ba.omarov@gmail.com>
Thu, 28 Jan 2021 09:39:53 +0000 (09:39 +0000)
lib/mix/tasks/pleroma/instance.ex

index f272fdb7f95abe29b1d56fc1b2f85a37e57655bc..ffe580fa79ffa2f284c22bba3f3cac3e7d08e2cd 100644 (file)
@@ -242,6 +242,13 @@ defmodule Mix.Tasks.Pleroma.Instance do
           rum_enabled: rum_enabled
         )
 
+      config_dir = Path.dirname(config_path)
+      psql_dir = Path.dirname(psql_path)
+      
+      [config_dir, psql_dir, static_dir, uploads_dir]
+      |> Enum.reject(&File.exists?/1)
+      |> Enum.map(&File.mkdir_p!/1)
+
       shell_info("Writing config to #{config_path}.")
 
       File.write(config_path, result_config)
@@ -275,10 +282,6 @@ defmodule Mix.Tasks.Pleroma.Instance do
         indexable: indexable
       )
 
-    unless File.exists?(static_dir) do
-      File.mkdir_p!(static_dir)
-    end
-
     robots_txt_path = Path.join(static_dir, "robots.txt")
 
     if File.exists?(robots_txt_path) do