commit: 1d743ca829027052f2f97f4d4ff5d35fc06e598c
parent: d1a6f67b1d92e17f4fe3cfc8f296879326897220
Author: lain <lain@soykaf.club>
Date: Thu, 3 Sep 2020 09:56:17 +0000
Merge branch 'fix_install_fe_bug' into 'develop'
Fix frontend install mix task bug
See merge request pleroma/pleroma!2942
Diffstat:
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/lib/mix/tasks/pleroma/frontend.ex b/lib/mix/tasks/pleroma/frontend.ex
@@ -69,7 +69,7 @@ defmodule Mix.Tasks.Pleroma.Frontend do
fe_label = "#{frontend} (#{ref})"
- tmp_dir = Path.join(dest, "tmp")
+ tmp_dir = Path.join([instance_static_dir, "frontends", "tmp"])
with {_, :ok} <-
{:download_or_unzip, download_or_unzip(frontend_info, tmp_dir, options[:file])},
@@ -135,6 +135,7 @@ defmodule Mix.Tasks.Pleroma.Frontend do
defp install_frontend(frontend_info, source, dest) do
from = frontend_info["build_dir"] || "dist"
+ File.rm_rf!(dest)
File.mkdir_p!(dest)
File.cp_r!(Path.join([source, from]), dest)
:ok
diff --git a/test/tasks/frontend_test.exs b/test/tasks/frontend_test.exs
@@ -48,11 +48,18 @@ defmodule Pleroma.FrontendTest do
}
})
+ folder = Path.join([@dir, "frontends", "pleroma", "fantasy"])
+ previously_existing = Path.join([folder, "temp"])
+ File.mkdir_p!(folder)
+ File.write!(previously_existing, "yey")
+ assert File.exists?(previously_existing)
+
capture_io(fn ->
Frontend.run(["install", "pleroma", "--file", "test/fixtures/tesla_mock/frontend.zip"])
end)
- assert File.exists?(Path.join([@dir, "frontends", "pleroma", "fantasy", "test.txt"]))
+ assert File.exists?(Path.join([folder, "test.txt"]))
+ refute File.exists?(previously_existing)
end
test "it downloads and unzips unknown frontends" do