From 8c470c6a01ab8ee12b7797eb245f8163692e469b Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 9 Nov 2015 18:41:31 +0100 Subject: [PATCH] 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. --- mod_http_upload/src/mod_http_upload.erl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mod_http_upload/src/mod_http_upload.erl b/mod_http_upload/src/mod_http_upload.erl index 3d54ca3..37d3306 100644 --- a/mod_http_upload/src/mod_http_upload.erl +++ b/mod_http_upload/src/mod_http_upload.erl @@ -758,7 +758,7 @@ store_file(Path, Data, FileMode, DirMode, GetPrefix, LocalPath, Thumbnail) -> <<"text/xml; charset=utf-8">>}], xml:element_to_binary(ThumbEl)} end; - {error, _} -> + pass -> ok end; ok -> @@ -855,7 +855,7 @@ code_to_message(_Code) -> <<"">>. %%-------------------------------------------------------------------- %% Image manipulation stuff %%-------------------------------------------------------------------- --spec identify(binary()) -> {ok, media_info()} | {error, binary()}. +-spec identify(binary()) -> {ok, media_info()} | pass. identify(Path) -> Cmd = lists:flatten(io_lib:fwrite("identify -format \"ok %m %h %w\" ~s", @@ -869,7 +869,7 @@ identify(Path) -> width = list_to_integer(W)}}; _ -> ?DEBUG("failed to identify type of ~s: ~s", [Path, Res]), - {error, list_to_binary(Res)} + pass end. -spec convert(binary(), media_info()) -> {ok, binary()} | pass. @@ -911,7 +911,7 @@ thumb_el(Path, URI) -> {<<"uri">>, URI}, {<<"height">>, jlib:integer_to_binary(H)}, {<<"width">>, jlib:integer_to_binary(W)}]}; - {error, _} -> + pass -> #xmlel{name = <<"thumbnail">>, attrs = [{<<"xmlns">>, ?NS_THUMBS_1}, {<<"uri">>, URI},