From a2b82dae69322f4faa5f0c09eff83f25f68aa263 Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Thu, 30 Mar 2023 17:40:53 -0300 Subject: [PATCH] fix(plugins): create directory before uploading Fixes https://emqx.atlassian.net/browse/EMQX-9434 Fixes https://github.com/emqx/emqx-elixir-plugin/issues/23 --- apps/emqx_management/src/emqx_mgmt_api_plugins.erl | 1 + changes/ce/fix-10300.en.md | 1 + mix.exs | 3 +++ 3 files changed, 5 insertions(+) create mode 100644 changes/ce/fix-10300.en.md diff --git a/apps/emqx_management/src/emqx_mgmt_api_plugins.erl b/apps/emqx_management/src/emqx_mgmt_api_plugins.erl index a46584f7f..92814d112 100644 --- a/apps/emqx_management/src/emqx_mgmt_api_plugins.erl +++ b/apps/emqx_management/src/emqx_mgmt_api_plugins.erl @@ -428,6 +428,7 @@ update_boot_order(post, #{bindings := #{name := Name}, body := Body}) -> %% For RPC upload_install/2 install_package(FileName, Bin) -> File = filename:join(emqx_plugins:install_dir(), FileName), + ok = filelib:ensure_dir(File), ok = file:write_file(File, Bin), PackageName = string:trim(FileName, trailing, ".tar.gz"), case emqx_plugins:ensure_installed(PackageName) of diff --git a/changes/ce/fix-10300.en.md b/changes/ce/fix-10300.en.md new file mode 100644 index 000000000..a60f9dfcd --- /dev/null +++ b/changes/ce/fix-10300.en.md @@ -0,0 +1 @@ +Fixed an issue where a build made with Elixir could not receive uploaded plugins until the `plugins` folder was created manually to receive the uploaded files. diff --git a/mix.exs b/mix.exs index ffa2ce056..514c9139d 100644 --- a/mix.exs +++ b/mix.exs @@ -394,10 +394,12 @@ defmodule EMQXUmbrella.MixProject do bin = Path.join(release.path, "bin") etc = Path.join(release.path, "etc") log = Path.join(release.path, "log") + plugins = Path.join(release.path, "plugins") Mix.Generator.create_directory(bin) Mix.Generator.create_directory(etc) Mix.Generator.create_directory(log) + Mix.Generator.create_directory(plugins) Mix.Generator.create_directory(Path.join(etc, "certs")) Enum.each( @@ -610,6 +612,7 @@ defmodule EMQXUmbrella.MixProject do &[ "etc", "data", + "plugins", "bin/node_dump" | &1 ]