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 ### Changed
* * incorrectly raised download cancelled error for already verified blob files
* *
### Added ### Added

View file

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

View file

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