Merge pull request #1127 from jakedt/torrent
Fix a bug with torrent calculation on duplicate v2 uploads
This commit is contained in:
commit
964edfdc4d
1 changed files with 3 additions and 2 deletions
|
@ -275,7 +275,8 @@ def _finish_upload(namespace, repo_name, upload_obj, expected_digest):
|
|||
|
||||
# Move the storage into place, or if this was a re-upload, cancel it
|
||||
with database.CloseForLongOperation(app.config):
|
||||
if storage.exists({upload_obj.location.name}, final_blob_location):
|
||||
already_exists = storage.exists({upload_obj.location.name}, final_blob_location)
|
||||
if already_exists:
|
||||
# It already existed, clean up our upload which served as proof that we had the file
|
||||
storage.cancel_chunked_upload({upload_obj.location.name}, upload_obj.uuid,
|
||||
upload_obj.storage_metadata)
|
||||
|
@ -293,7 +294,7 @@ def _finish_upload(namespace, repo_name, upload_obj, expected_digest):
|
|||
app.config['PUSH_TEMP_TAG_EXPIRATION_SEC'],
|
||||
upload_obj.uncompressed_byte_count)
|
||||
|
||||
if upload_obj.piece_sha_state is not None:
|
||||
if upload_obj.piece_sha_state is not None and not already_exists:
|
||||
piece_bytes = upload_obj.piece_hashes + upload_obj.piece_sha_state.digest()
|
||||
model.storage.save_torrent_info(blob_storage, app.config['TORRENT_PIECE_SIZE'], piece_bytes)
|
||||
|
||||
|
|
Reference in a new issue