Fix piece hash calculation
This commit is contained in:
parent
d83cc109b5
commit
e4da61a05d
3 changed files with 16 additions and 6 deletions
|
@ -224,11 +224,17 @@ def _upload_chunk(namespace, repo_name, upload_uuid):
|
|||
|
||||
input_fp = wrap_with_handler(input_fp, found.sha_state.update)
|
||||
|
||||
# Add a hasher for calculating SHA1s for torrents if this is the first chunk and/or we have
|
||||
# already calculated hash data for the previous chunk(s).
|
||||
piece_hasher = None
|
||||
# TODO remove this when all in-progress blob uploads reliably contain piece hashes
|
||||
if start_offset == 0:
|
||||
piece_hasher = PieceHasher(app.config['TORRENT_PIECE_SIZE'], start_offset, '',
|
||||
resumablehashlib.sha1())
|
||||
if found.chunk_count == 0 or found.piece_sha_state:
|
||||
initial_sha1_value = found.piece_sha_state or resumablehashlib.sha1()
|
||||
initial_sha1_pieces_value = found.piece_hashes or ''
|
||||
|
||||
piece_hasher = PieceHasher(app.config['TORRENT_PIECE_SIZE'], start_offset,
|
||||
initial_sha1_pieces_value,
|
||||
initial_sha1_value)
|
||||
|
||||
input_fp = wrap_with_handler(input_fp, piece_hasher.update)
|
||||
|
||||
# If this is the first chunk and we're starting at the 0 offset, add a handler to gunzip the
|
||||
|
|
Reference in a new issue