Fix a bug with torrent calculation on duplicate v2 uploads
This commit is contained in:
parent
932d892276
commit
17d3b5e204
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
|
# Move the storage into place, or if this was a re-upload, cancel it
|
||||||
with database.CloseForLongOperation(app.config):
|
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
|
# 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,
|
storage.cancel_chunked_upload({upload_obj.location.name}, upload_obj.uuid,
|
||||||
upload_obj.storage_metadata)
|
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'],
|
app.config['PUSH_TEMP_TAG_EXPIRATION_SEC'],
|
||||||
upload_obj.uncompressed_byte_count)
|
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()
|
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)
|
model.storage.save_torrent_info(blob_storage, app.config['TORRENT_PIECE_SIZE'], piece_bytes)
|
||||||
|
|
||||||
|
|
Reference in a new issue