diff options
| -rw-r--r-- | src/rabbit_plugin_activator.erl | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/rabbit_plugin_activator.erl b/src/rabbit_plugin_activator.erl index e10ef9996f..34df9c483f 100644 --- a/src/rabbit_plugin_activator.erl +++ b/src/rabbit_plugin_activator.erl @@ -129,8 +129,24 @@ assert_dir(Dir) -> ok = filelib:ensure_dir(Dir), ok = file:make_dir(Dir) end. - +delete_dir(Dir) -> + case filelib:is_dir(Dir) of + true -> + case file:list_dir(Dir) of + {ok, Files} -> + Paths = [Dir ++ "/" ++ F || F <- Files], + [delete_dir(F) || F <- Paths, filelib:is_dir(F)], + [file:delete(F) || F <- Paths, filelib:is_file(F)] + end, + ok = file:del_dir(Dir); + false -> + ok + end. + unpack_ez_plugins(PluginSrcDir, PluginDestDir) -> + % Eliminate the contents of the destination directory + delete_dir(PluginDestDir), + assert_dir(PluginDestDir), [unpack_ez_plugin(PluginName, PluginDestDir) || PluginName <- filelib:wildcard(PluginSrcDir ++ "/*.ez")]. @@ -138,6 +154,7 @@ unpack_ez_plugin(PluginFn, PluginDestDir) -> zip:unzip(PluginFn, [{cwd, PluginDestDir}]), ok. + find_plugins(PluginDir) -> [prepare_dir_plugin(PluginName) || PluginName <- filelib:wildcard(PluginDir ++ "/*/ebin/*.app")]. @@ -172,4 +189,4 @@ expand_dependencies(Current, [Next|Rest]) -> {ok, Required} = application:get_key(Next, applications), Unique = [A || A <- Required, not(sets:is_element(A, Current))], expand_dependencies(sets:add_element(Next, Current), Rest ++ Unique) - end.
\ No newline at end of file + end. |
