remove HashBob._close_writer(), move the closing of write handler to HashBlobWriter
This commit is contained in:
parent
0f95712a0f
commit
94ff4e82bc
1 changed files with 3 additions and 11 deletions
|
@ -74,6 +74,9 @@ class HashBlobWriter(object):
|
|||
def close(self, reason=None):
|
||||
if reason is None:
|
||||
reason = Failure(DownloadCanceledError())
|
||||
if self.write_handle is not None:
|
||||
self.write_handle.close()
|
||||
self.write_handle = None
|
||||
|
||||
self.finished_cb(self, reason)
|
||||
|
||||
|
@ -137,7 +140,6 @@ class HashBlob(object):
|
|||
return d
|
||||
|
||||
def writer_finished(self, writer, err=None):
|
||||
|
||||
def fire_finished_deferred():
|
||||
self._verified = True
|
||||
for p, (w, finished_deferred) in self.writers.items():
|
||||
|
@ -179,7 +181,6 @@ class HashBlob(object):
|
|||
errback_finished_deferred(err)
|
||||
d = defer.succeed(True)
|
||||
|
||||
d.addBoth(lambda _: self._close_writer(writer))
|
||||
return d
|
||||
|
||||
def open_for_writing(self, peer):
|
||||
|
@ -194,9 +195,6 @@ class HashBlob(object):
|
|||
def close_read_handle(self, file_handle):
|
||||
raise NotImplementedError()
|
||||
|
||||
def _close_writer(self, writer):
|
||||
raise NotImplementedError()
|
||||
|
||||
def _save_verified_blob(self, writer):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
@ -301,12 +299,6 @@ class BlobFile(HashBlob):
|
|||
file_handle.close()
|
||||
self.readers -= 1
|
||||
|
||||
def _close_writer(self, writer):
|
||||
if writer.write_handle is not None:
|
||||
log.debug("Closing %s", str(self))
|
||||
writer.write_handle.close()
|
||||
writer.write_handle = None
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _save_verified_blob(self, writer):
|
||||
with self.setting_verified_blob_lock:
|
||||
|
|
Loading…
Reference in a new issue