From 9f13bb8960df817bfb1dc7f19dffd2d476622adc Mon Sep 17 00:00:00 2001 From: Jake Moshenko Date: Thu, 10 Dec 2015 13:14:11 -0500 Subject: [PATCH] Fix the overlap condition on resumed uploads --- endpoints/v2/blob.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/endpoints/v2/blob.py b/endpoints/v2/blob.py index 42439650a..52782bb4f 100644 --- a/endpoints/v2/blob.py +++ b/endpoints/v2/blob.py @@ -204,8 +204,17 @@ def _upload_chunk(namespace, repo_name, upload_uuid): if start_offset > 0 and start_offset < found.byte_count: # Skip the bytes which were received on a previous push, which are already stored and # included in the sha calculation - input_fp = StreamSlice(input_fp, found.byte_count - start_offset) + overlap_size = found.byte_count - start_offset + input_fp = StreamSlice(input_fp, overlap_size) + + # Update our upload bounds to reflect the skipped portion of the overlap start_offset = found.byte_count + length = max(length - overlap_size, 0) + + # We use this to escape early in case we have already processed all of the bytes the user + # wants to upload + if length == 0: + return found input_fp = wrap_with_handler(input_fp, found.sha_state.update)