mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
mod_http_upload: Don't let identify/1 return error
Let identify/1 return 'pass' when it failed to identify the file type, as this doesn't (necessarily) indicate an error condition. This also makes it consistent with the return value of convert/2.
This commit is contained in:
parent
58c1bc4276
commit
9c80cb2b26
@ -776,7 +776,7 @@ store_file(Path, Data, FileMode, DirMode, GetPrefix, LocalPath, Thumbnail) ->
|
|||||||
<<"text/xml; charset=utf-8">>}],
|
<<"text/xml; charset=utf-8">>}],
|
||||||
xml:element_to_binary(ThumbEl)}
|
xml:element_to_binary(ThumbEl)}
|
||||||
end;
|
end;
|
||||||
{error, _} ->
|
pass ->
|
||||||
ok
|
ok
|
||||||
end;
|
end;
|
||||||
ok ->
|
ok ->
|
||||||
@ -873,7 +873,7 @@ code_to_message(_Code) -> <<"">>.
|
|||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Image manipulation stuff
|
%% Image manipulation stuff
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
-spec identify(binary()) -> {ok, media_info()} | {error, binary()}.
|
-spec identify(binary()) -> {ok, media_info()} | pass.
|
||||||
|
|
||||||
identify(Path) ->
|
identify(Path) ->
|
||||||
Cmd = lists:flatten(io_lib:fwrite("identify -format \"ok %m %h %w\" ~s",
|
Cmd = lists:flatten(io_lib:fwrite("identify -format \"ok %m %h %w\" ~s",
|
||||||
@ -887,7 +887,7 @@ identify(Path) ->
|
|||||||
width = list_to_integer(W)}};
|
width = list_to_integer(W)}};
|
||||||
_ ->
|
_ ->
|
||||||
?DEBUG("failed to identify type of ~s: ~s", [Path, Res]),
|
?DEBUG("failed to identify type of ~s: ~s", [Path, Res]),
|
||||||
{error, list_to_binary(Res)}
|
pass
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec convert(binary(), media_info()) -> {ok, binary()} | pass.
|
-spec convert(binary(), media_info()) -> {ok, binary()} | pass.
|
||||||
@ -929,7 +929,7 @@ thumb_el(Path, URI) ->
|
|||||||
{<<"uri">>, URI},
|
{<<"uri">>, URI},
|
||||||
{<<"height">>, jlib:integer_to_binary(H)},
|
{<<"height">>, jlib:integer_to_binary(H)},
|
||||||
{<<"width">>, jlib:integer_to_binary(W)}]};
|
{<<"width">>, jlib:integer_to_binary(W)}]};
|
||||||
{error, _} ->
|
pass ->
|
||||||
#xmlel{name = <<"thumbnail">>,
|
#xmlel{name = <<"thumbnail">>,
|
||||||
attrs = [{<<"xmlns">>, ?NS_THUMBS_1},
|
attrs = [{<<"xmlns">>, ?NS_THUMBS_1},
|
||||||
{<<"uri">>, URI},
|
{<<"uri">>, URI},
|
||||||
|
Loading…
Reference in New Issue
Block a user