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