diff options
| author | Michael Klishin <michael@novemberain.com> | 2017-05-27 00:44:51 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-27 00:44:51 +0300 |
| commit | 9084194f327275b268e64e5f9928eb1e91a50219 (patch) | |
| tree | e4617c71fa46912e547920517a78786fb07f25d0 | |
| parent | 904e5274b09eb55dfbad67de0a48e0f09410e134 (diff) | |
| parent | 7c8ccae3b3821740dd66cf61b307e9682b132c65 (diff) | |
| download | rabbitmq-server-git-9084194f327275b268e64e5f9928eb1e91a50219.tar.gz | |
Merge pull request #1226 from binarin/dont-expand-dir-plugins-stable
Don't expand plugins that are already unpacked
| -rw-r--r-- | src/rabbit_plugins.erl | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl index a5d7de56bb..7c1217c543 100644 --- a/src/rabbit_plugins.erl +++ b/src/rabbit_plugins.erl @@ -103,7 +103,7 @@ setup() -> %% @doc Lists the plugins which are currently running. active() -> - InstalledPlugins = plugin_names(list(plugins_expand_dir())), + InstalledPlugins = plugin_names(list(plugins_dist_dir())), [App || {App, _, _} <- rabbit_misc:which_applications(), lists:member(App, InstalledPlugins)]. @@ -200,9 +200,6 @@ prepare_plugins(Enabled) -> end, [prepare_plugin(Plugin, ExpandDir) || Plugin <- WantedPlugins], - - [prepare_dir_plugin(PluginAppDescPath) || - PluginAppDescPath <- filelib:wildcard(ExpandDir ++ "/*/ebin/*.app")], Wanted. clean_plugins(Plugins) -> @@ -250,11 +247,37 @@ delete_recursively(Fn) -> {error, {Path, E}} -> {error, {cannot_delete, Path, E}} end. -prepare_plugin(#plugin{type = ez, location = Location}, ExpandDir) -> - zip:unzip(Location, [{cwd, ExpandDir}]); -prepare_plugin(#plugin{type = dir, name = Name, location = Location}, - ExpandDir) -> - rabbit_file:recursive_copy(Location, filename:join([ExpandDir, Name])). +find_unzipped_app_file(ExpandDir, Files) -> + StripComponents = length(filename:split(ExpandDir)), + [ X || X <- Files, + [_AppName, "ebin", MaybeAppFile] <- + [lists:nthtail(StripComponents, filename:split(X))], + lists:suffix(".app", MaybeAppFile) + ]. + +prepare_plugin(#plugin{type = ez, name = Name, location = Location}, ExpandDir) -> + case zip:unzip(Location, [{cwd, ExpandDir}]) of + {ok, Files} -> + case find_unzipped_app_file(ExpandDir, Files) of + [PluginAppDescPath|_] -> + prepare_dir_plugin(PluginAppDescPath); + _ -> + rabbit_log:error("Plugin archive '~s' doesn't contain an .app file~n", [Location]), + throw({app_file_missing, Name, Location}) + end; + {error, Reason} -> + rabbit_log:error("Could not unzip plugin archive '~s': ~p~n", [Location, Reason]), + throw({failed_to_unzip_plugin, Name, Location, Reason}) + end; +prepare_plugin(#plugin{type = dir, location = Location, name = Name}, + _ExpandDir) -> + case filelib:wildcard(Location ++ "/ebin/*.app") of + [PluginAppDescPath|_] -> + prepare_dir_plugin(PluginAppDescPath); + _ -> + rabbit_log:error("Plugin directory '~s' doesn't contain an .app file~n", [Location]), + throw({app_file_missing, Name, Location}) + end. plugin_info({ez, EZ}) -> case read_app_file(EZ) of |
