From ee3efbc2fe78b5594d04d0226ff579a71f3a0f2c Mon Sep 17 00:00:00 2001 From: mocchira Date: Wed, 4 Oct 2017 14:33:00 +0900 Subject: [PATCH] gateway: Fix #845 --- apps/leo_gateway/src/leo_gateway_s3_api.erl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/leo_gateway/src/leo_gateway_s3_api.erl b/apps/leo_gateway/src/leo_gateway_s3_api.erl index 0430b628..7f535c23 100644 --- a/apps/leo_gateway/src/leo_gateway_s3_api.erl +++ b/apps/leo_gateway/src/leo_gateway_s3_api.erl @@ -1192,8 +1192,6 @@ handle_multi_upload_1(true, Req, Path, UploadId, case leo_gateway_rpc_handler:get(Path4Conf) of {ok, #?METADATA{meta = CMetaBin}, _} -> - _ = leo_gateway_rpc_handler:delete(Path4Conf), - BodyOpts = case TransferDecodeFun of undefined -> []; @@ -1201,7 +1199,12 @@ handle_multi_upload_1(true, Req, Path, UploadId, [{transfer_decode, TransferDecodeFun, TransferDecodeState}] end, Ret = cowboy_req:body(Req, BodyOpts), - handle_multi_upload_2(Ret, Req, Path, ChunkedLen, BucketInfo, CMetaBin); + {ok, Req2} = handle_multi_upload_2(Ret, Req, Path, ChunkedLen, BucketInfo, CMetaBin), + %% Deleting a temporary object after getting the upload done could decrease the odds + %% inconsistencies against the temporary object could happen. + %% This hack should mitigate https://github.com/leo-project/leofs/issues/845 + _ = leo_gateway_rpc_handler:delete(Path4Conf), + {ok, Req2}; _ -> ?reply_service_unavailable_error([?SERVER_HEADER], Path, <<>>, Req) end;