fix position of stream terminator blob

This commit is contained in:
Jack Robison 2018-02-21 16:37:00 -05:00
parent 3e6b00ad00
commit d7bfeae6b8
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -86,10 +86,9 @@ class CryptStreamCreator(object):
self.stopped = True
if self.current_blob is not None:
self._close_current_blob()
self._finalize()
dl = defer.DeferredList(self.finished_deferreds)
dl.addCallback(lambda _: self._finished())
return dl
d = self._finalize()
d.addCallback(lambda _: self._finished())
return d
# TODO: move the stream creation process to its own thread and
# remove the reactor from this process.
@ -112,6 +111,7 @@ class CryptStreamCreator(object):
return defer.succeed(True)
@defer.inlineCallbacks
def _finalize(self):
"""
Finalize a stream by adding an empty
@ -119,14 +119,14 @@ class CryptStreamCreator(object):
the stream has ended. This empty blob is not
saved to the blob manager
"""
log.debug("_finalize has been called")
yield defer.DeferredList(self.finished_deferreds)
self.blob_count += 1
iv = self.iv_generator.next()
final_blob_creator = self.blob_manager.get_blob_creator()
final_blob = self._get_blob_maker(iv, final_blob_creator)
d = final_blob.close()
d.addCallback(self._blob_finished)
self.finished_deferreds.append(d)
final_blob = self._get_blob_maker(iv, self.blob_manager.get_blob_creator())
stream_terminator = yield final_blob.close()
terminator_info = yield self._blob_finished(stream_terminator)
defer.returnValue(terminator_info)
def _write(self, data):
while len(data) > 0: