mod_spam_filter: Auto-create dump directory

If the directory holding the specified "spam_dump_file" doesn't exist,
create it on startup.
This commit is contained in:
Holger Weiss 2019-04-25 18:23:17 +02:00
parent fe121057f2
commit 92fadcdf4e
1 changed files with 9 additions and 2 deletions

View File

@ -157,12 +157,19 @@ init([Host, Opts]) ->
DumpFd = if DumpFile == none ->
undefined;
true ->
case filelib:ensure_dir(DumpFile) of
ok ->
ok;
{error, Reason} ->
Dirname = filename:dirname(DumpFile),
throw({open, Dirname, Reason})
end,
Modes = [append, raw, binary, delayed_write],
case file:open(DumpFile, Modes) of
{ok, Fd} ->
Fd;
{error, Reason} ->
throw({open, DumpFile, Reason})
{error, Reason1} ->
throw({open, DumpFile, Reason1})
end
end,
{ok, #state{host = Host,