fix incorrectly raised DownloadCanceledError for already verified blobs

-make InvalidDataError message clearer
-fix BlobReflectorClient result
This commit is contained in:
Jack Robison 2018-03-22 13:23:12 -04:00
parent 0cbe11b263
commit 679c2f403f
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
3 changed files with 10 additions and 9 deletions

View file

@ -21,7 +21,7 @@ at anytime.
*
### Changed
*
* incorrectly raised download cancelled error for already verified blob files
*
### Added

View file

@ -176,17 +176,18 @@ class BlobFile(object):
d.addCallbacks(lambda _: fire_finished_deferred(), errback_finished_deferred)
d.addCallback(lambda _: cancel_other_downloads())
else:
errback_finished_deferred(Failure(DownloadCanceledError()))
d = defer.succeed(True)
d = defer.succeed(None)
fire_finished_deferred()
else:
err_string = "length vs expected: {0}, {1}, hash vs expected: {2}, {3}"
err_string = err_string.format(self.length, writer.len_so_far, self.blob_hash,
writer.blob_hash)
if writer.len_so_far != self.length:
err_string = "blob length is %i vs expected %i" % (writer.len_so_far, self.length)
else:
err_string = "blob hash is %s vs expected %s" % (writer.blob_hash, self.blob_hash)
errback_finished_deferred(Failure(InvalidDataError(err_string)))
d = defer.succeed(True)
d = defer.succeed(None)
else:
errback_finished_deferred(err)
d = defer.succeed(True)
d = defer.succeed(None)
d.addBoth(lambda _: writer.close_handle())
return d

View file

@ -49,7 +49,7 @@ class BlobReflectorClient(Protocol):
self.factory.sent_blobs = self.sent_blobs
if self.factory.sent_blobs:
log.info('Finished sending data via reflector')
self.factory.finished_deferred.callback(True)
self.factory.finished_deferred.callback(self.factory.sent_blobs)
else:
log.info('Reflector finished: %s', reason)
self.factory.finished_deferred.callback(reason)