mod_http_upload: Set mode bits of all directories

When the "dir_mode" option is specified and the file root/a/b/file.png
is uploaded, make sure the permissions of the "a" directory are also
set.
This commit is contained in:
Holger Weiss 2015-09-14 00:55:38 +02:00
parent f3bf402e7a
commit a6c7dc9b8a
1 changed files with 13 additions and 10 deletions

View File

@ -661,13 +661,16 @@ store_file(Path, Data, FileMode, DirMode) ->
{ok, Io} = file:open(Path, [write, exclusive, raw]),
Ok = file:write(Io, Data),
ok = file:close(Io),
ok = if is_integer(FileMode) ->
file:change_mode(Path, FileMode);
if is_integer(FileMode) ->
ok = file:change_mode(Path, FileMode);
FileMode == undefined ->
ok
end,
ok = if is_integer(DirMode) ->
file:change_mode(filename:dirname(Path), DirMode);
if is_integer(DirMode) ->
RandDir = filename:dirname(Path),
UserDir = filename:dirname(RandDir),
ok = file:change_mode(RandDir, DirMode),
ok = file:change_mode(UserDir, DirMode);
DirMode == undefined ->
ok
end,