Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix to handle errors correctly

  • Loading branch information...
commit 63a1dbba45991e8cbd170a388ad998bfebf5011a 1 parent d95e0ee
@mocchira mocchira authored
Showing with 8 additions and 3 deletions.
  1. +8 −3 src/leo_gateway_http_commons.erl
View
11 src/leo_gateway_http_commons.erl
@@ -350,11 +350,17 @@ move_large_object(#metadata{dsize = Size}, DstKey,
ReadHandler) ->
{ok, WriteHandler} = leo_gateway_large_object_handler:start_link(DstKey, ChunkedSize),
try
- move_large_object_1(leo_gateway_large_object_handler:get_chunked(ReadHandler),
+ case move_large_object_1(leo_gateway_large_object_handler:get_chunked(ReadHandler),
#req_large_obj{handler = WriteHandler,
key = DstKey,
length = Size,
- chunked_size = ChunkedSize}, ReadHandler)
+ chunked_size = ChunkedSize}, ReadHandler) of
+ {error, Cause} ->
+ ok = leo_gateway_large_object_handler:rollback(WriteHandler),
+ {error, Cause};
+ Other ->
+ Other
+ end
after
catch leo_gateway_large_object_handler:stop(WriteHandler)
end.
@@ -375,7 +381,6 @@ move_large_object_1({ok, Data},
move_large_object_1({error, Cause},
#req_large_obj{key = Key,
handler = WriteHandler}, _) ->
- ok = leo_gateway_large_object_handler:rollback(WriteHandler),
?error("move_large_object_1/3", "key:~s, cause:~p", [binary_to_list(Key), Cause]),
{error, ?ERROR_FAIL_RETRIEVE_OBJ};
move_large_object_1(done, #req_large_obj{handler = WriteHandler,
Please sign in to comment.
Something went wrong with that request. Please try again.