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:
parent
f3bf402e7a
commit
a6c7dc9b8a
|
@ -661,13 +661,16 @@ store_file(Path, Data, FileMode, DirMode) ->
|
||||||
{ok, Io} = file:open(Path, [write, exclusive, raw]),
|
{ok, Io} = file:open(Path, [write, exclusive, raw]),
|
||||||
Ok = file:write(Io, Data),
|
Ok = file:write(Io, Data),
|
||||||
ok = file:close(Io),
|
ok = file:close(Io),
|
||||||
ok = if is_integer(FileMode) ->
|
if is_integer(FileMode) ->
|
||||||
file:change_mode(Path, FileMode);
|
ok = file:change_mode(Path, FileMode);
|
||||||
FileMode == undefined ->
|
FileMode == undefined ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
ok = if is_integer(DirMode) ->
|
if is_integer(DirMode) ->
|
||||||
file:change_mode(filename:dirname(Path), DirMode);
|
RandDir = filename:dirname(Path),
|
||||||
|
UserDir = filename:dirname(RandDir),
|
||||||
|
ok = file:change_mode(RandDir, DirMode),
|
||||||
|
ok = file:change_mode(UserDir, DirMode);
|
||||||
DirMode == undefined ->
|
DirMode == undefined ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Reference in New Issue