From 855ab772a800c522cca58e67140f833fa7815034 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Mon, 11 Sep 2017 18:24:06 -0300 Subject: [bug] close consumer on FileBodyProducer It isn't closed by Twisted like the producer is. -- Resolves: #8924 -- Related: #8932 --- src/leap/soledad/client/_db/blobs.py | 3 ++- src/leap/soledad/server/_blobs.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/leap/soledad/client/_db/blobs.py b/src/leap/soledad/client/_db/blobs.py index 0374ae94..cfabda74 100644 --- a/src/leap/soledad/client/_db/blobs.py +++ b/src/leap/soledad/client/_db/blobs.py @@ -469,7 +469,8 @@ class SQLiteBlobBackend(object): # have a look at how treq does cope with closing the handle # for uploading a file producer = FileBodyProducer(blob_fd) - done = yield producer.startProducing(handle) + with handle: + done = yield producer.startProducing(handle) logger.info("Finished saving blob in local database.") defer.returnValue(done) diff --git a/src/leap/soledad/server/_blobs.py b/src/leap/soledad/server/_blobs.py index f7db9218..790a9b51 100644 --- a/src/leap/soledad/server/_blobs.py +++ b/src/leap/soledad/server/_blobs.py @@ -121,7 +121,8 @@ class FilesystemBlobsBackend(object): defer.returnValue(None) logger.info('writing blob: %s - %s' % (user, blob_id)) fbp = FileBodyProducer(request.content) - yield fbp.startProducing(open(path, 'wb')) + with open(path, 'wb') as blobfile: + yield fbp.startProducing(blobfile) def delete_blob(self, user, blob_id, namespace=''): blob_path = self._get_path(user, blob_id, namespace) -- cgit v1.2.3