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:
parent
fe121057f2
commit
92fadcdf4e
|
@ -157,12 +157,19 @@ init([Host, Opts]) ->
|
||||||
DumpFd = if DumpFile == none ->
|
DumpFd = if DumpFile == none ->
|
||||||
undefined;
|
undefined;
|
||||||
true ->
|
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],
|
Modes = [append, raw, binary, delayed_write],
|
||||||
case file:open(DumpFile, Modes) of
|
case file:open(DumpFile, Modes) of
|
||||||
{ok, Fd} ->
|
{ok, Fd} ->
|
||||||
Fd;
|
Fd;
|
||||||
{error, Reason} ->
|
{error, Reason1} ->
|
||||||
throw({open, DumpFile, Reason})
|
throw({open, DumpFile, Reason1})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
{ok, #state{host = Host,
|
{ok, #state{host = Host,
|
||||||
|
|
Loading…
Reference in New Issue