summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2010-08-27 14:33:39 +0100
committerSimon MacMullen <simon@rabbitmq.com>2010-08-27 14:33:39 +0100
commit108641adddafc255574ef4031e4324068a7771cf (patch)
tree0c7f7aba9518b42c240f06db15e637345804c8cc /src
parentab9623206b797544a8da6f853d874de7bc15ac0a (diff)
downloadrabbitmq-server-git-108641adddafc255574ef4031e4324068a7771cf.tar.gz
Increase robustness when the scratch dir cannot be deleted / written.
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_plugin_activator.erl26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/rabbit_plugin_activator.erl b/src/rabbit_plugin_activator.erl
index 26274a365e..0172a880b7 100644
--- a/src/rabbit_plugin_activator.erl
+++ b/src/rabbit_plugin_activator.erl
@@ -140,6 +140,20 @@ start() ->
stop() ->
ok.
+fail(Context, Error) ->
+ io:format("~n~nERROR:~n", []),
+ case {Context, Error} of
+ {{delete_dir, Dir}, _} ->
+ io:format("Could not delete ~s~n", [Dir]);
+ {{assert_dir, Dir}, _} ->
+ io:format("Could not create ~s~n", [Dir]);
+ _ ->
+ io:format("Unknown error: ~w in context ~w~n", [Error, Context])
+ end,
+ io:nl(),
+ halt(1),
+ ok.
+
get_env(Key, Default) ->
case application:get_env(rabbit, Key) of
{ok, V} -> V;
@@ -152,10 +166,9 @@ determine_version(App) ->
{App, Vsn}.
assert_dir(Dir) ->
- case filelib:is_dir(Dir) of
- true -> ok;
- false -> ok = filelib:ensure_dir(Dir),
- ok = file:make_dir(Dir)
+ case filelib:ensure_dir(Dir ++ "/") of
+ ok -> ok;
+ E -> fail({assert_dir, Dir}, E)
end.
delete_dir(Dir) ->
@@ -171,7 +184,10 @@ delete_dir(Dir) ->
end
end || F <- Files]
end,
- ok = file:del_dir(Dir);
+ case file:del_dir(Dir) of
+ ok -> ok;
+ E -> fail({delete_dir, Dir}, E)
+ end;
false ->
ok
end.