Fix torrent hash generation to work in mixed stacks

This commit is contained in:
Jake Moshenko 2016-01-11 16:43:20 -05:00
parent 8bc8e2acc0
commit 8ab6c8a22d
3 changed files with 12 additions and 7 deletions

View file

@ -3,6 +3,8 @@ import re
from flask import make_response, url_for, request, redirect, Response, abort as flask_abort
import resumablehashlib
from app import storage, app
from auth.registry_jwt_auth import process_registry_jwt_auth
from data import model, database
@ -224,9 +226,9 @@ def _upload_chunk(namespace, repo_name, upload_uuid):
piece_hasher = None
# TODO remove this when all in-progress blob uploads reliably contain piece hashes
if start_offset == 0 or found.piece_sha_state is not None:
piece_hasher = PieceHasher(app.config['TORRENT_PIECE_SIZE'], start_offset, found.piece_hashes,
found.piece_sha_state)
if start_offset == 0:
piece_hasher = PieceHasher(app.config['TORRENT_PIECE_SIZE'], start_offset, '',
resumablehashlib.sha1())
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