instance.gen task: fix crash when using custom static directory

Closes #1082
This commit is contained in:
rinpatch 2020-02-24 22:52:38 +03:00
parent d240ce41b5
commit 5e4fe0e8f7
2 changed files with 8 additions and 1 deletions

View file

@ -6,6 +6,8 @@ defmodule Mix.Tasks.Pleroma.Instance do
use Mix.Task use Mix.Task
import Mix.Pleroma import Mix.Pleroma
alias Pleroma.Config
@shortdoc "Manages Pleroma instance" @shortdoc "Manages Pleroma instance"
@moduledoc File.read!("docs/administration/CLI_tasks/instance.md") @moduledoc File.read!("docs/administration/CLI_tasks/instance.md")
@ -153,6 +155,8 @@ defmodule Mix.Tasks.Pleroma.Instance do
Pleroma.Config.get([:instance, :static_dir]) Pleroma.Config.get([:instance, :static_dir])
) )
Config.put([:instance, :static_dir], static_dir)
secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64) secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
jwt_secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64) jwt_secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
signing_salt = :crypto.strong_rand_bytes(8) |> Base.encode64() |> binary_part(0, 8) signing_salt = :crypto.strong_rand_bytes(8) |> Base.encode64() |> binary_part(0, 8)

View file

@ -3,9 +3,10 @@
# SPDX-License-Identifier: AGPL-3.0-only # SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.InstanceTest do defmodule Pleroma.InstanceTest do
use ExUnit.Case, async: true use ExUnit.Case
setup do setup do
static_dir = Pleroma.Config.get([:instance, :static_dir])
File.mkdir_p!(tmp_path()) File.mkdir_p!(tmp_path())
on_exit(fn -> on_exit(fn ->
@ -15,6 +16,8 @@ defmodule Pleroma.InstanceTest do
if File.exists?(static_dir) do if File.exists?(static_dir) do
File.rm_rf(Path.join(static_dir, "robots.txt")) File.rm_rf(Path.join(static_dir, "robots.txt"))
end end
Pleroma.Config.put([:instance, :static_dir], static_dir)
end) end)
:ok :ok