diff options
author | Paul Jones <paulj@lshift.net> | 2009-07-23 11:51:02 +0100 |
---|---|---|
committer | Paul Jones <paulj@lshift.net> | 2009-07-23 11:51:02 +0100 |
commit | 33c5fd5352d992adc20e7c92fb13856f297d5cba (patch) | |
tree | 361bd9a1003ccafa2d9b2a4acfca6f22386245c3 | |
parent | 041b8afc380b1b0b2a01d36e4c740c4b332336c0 (diff) | |
download | rabbitmq-server-33c5fd5352d992adc20e7c92fb13856f297d5cba.tar.gz |
Delete the plugin unpack directory before starting
-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 e10ef999..34df9c48 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. |