add HashBlobWriter.close_handle() function to just close the write handle
This commit is contained in:
parent
94ff4e82bc
commit
196aa24b8b
1 changed files with 8 additions and 4 deletions
|
@ -71,13 +71,17 @@ class HashBlobWriter(object):
|
|||
if self.len_so_far == self.length_getter():
|
||||
self.finished_cb(self)
|
||||
|
||||
def close(self, reason=None):
|
||||
if reason is None:
|
||||
reason = Failure(DownloadCanceledError())
|
||||
def close_handle(self):
|
||||
if self.write_handle is not None:
|
||||
self.write_handle.close()
|
||||
self.write_handle = None
|
||||
|
||||
def close(self, reason=None):
|
||||
# we've already closed, so do nothing
|
||||
if self.write_handle is None:
|
||||
return
|
||||
if reason is None:
|
||||
reason = Failure(DownloadCanceledError())
|
||||
self.finished_cb(self, reason)
|
||||
|
||||
|
||||
|
@ -180,7 +184,7 @@ class HashBlob(object):
|
|||
else:
|
||||
errback_finished_deferred(err)
|
||||
d = defer.succeed(True)
|
||||
|
||||
d.addBoth(lambda _: writer.close_handle())
|
||||
return d
|
||||
|
||||
def open_for_writing(self, peer):
|
||||
|
|
Loading…
Reference in a new issue