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,16 +661,19 @@ 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);
|
||||
FileMode == undefined ->
|
||||
ok
|
||||
end,
|
||||
ok = if is_integer(DirMode) ->
|
||||
file:change_mode(filename:dirname(Path), DirMode);
|
||||
DirMode == undefined ->
|
||||
ok
|
||||
end,
|
||||
if is_integer(FileMode) ->
|
||||
ok = file:change_mode(Path, FileMode);
|
||||
FileMode == undefined ->
|
||||
ok
|
||||
end,
|
||||
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,
|
||||
ok = Ok % Raise an exception if file:write/2 failed.
|
||||
catch
|
||||
_:{badmatch, {error, Error}} ->
|
||||
|
|
Loading…
Reference in New Issue