Proper error when piecemap download fails

This commit is contained in:
shortcutme 2020-01-22 16:31:35 +01:00
parent a16d55c863
commit 3e08eabc86
No known key found for this signature in database
GPG Key ID: 5B63BAE6CB9613AE
1 changed files with 6 additions and 1 deletions

View File

@ -33,6 +33,7 @@ def importPluginnedClasses():
from Content.ContentManager import VerifyError
from Config import config
if "upload_nonces" not in locals():
upload_nonces = {}
@ -340,7 +341,11 @@ class ContentManagerPlugin(object):
return piecemap
def verifyPiece(self, inner_path, pos, piece):
piecemap = self.getPiecemap(inner_path)
try:
piecemap = self.getPiecemap(inner_path)
except OSError as err:
raise VerifyError("Unable to download piecemap: %s" % err)
piece_i = int(pos / piecemap["piece_size"])
if CryptHash.sha512sum(piece, format="digest") != piecemap["sha512_pieces"][piece_i]:
raise VerifyError("Invalid hash")