summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-03-22 00:02:51 -0300
committerdrebs <drebs@leap.se>2017-04-04 18:27:37 +0200
commite90a424575b04c99696805adbd2cd01a0f4c7e46 (patch)
tree4c476698d06a15fd22d43c2947beb72c8da23020 /client
parenta44954eb34f1ba46eae17b281022e3c8b2fae889 (diff)
[bug] copy returns a closed handle
copy call returns a closed file handler, instead we can query for the blob after insertion and use the returned file handle to be consumed for upload. A better solution would be to "pipe" the writes into the database into the upload, but that involves solving a larger set of issues to be done later.
Diffstat (limited to 'client')
-rw-r--r--client/src/leap/soledad/client/_blobs.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/client/src/leap/soledad/client/_blobs.py b/client/src/leap/soledad/client/_blobs.py
index 2c613a80..92aa42cf 100644
--- a/client/src/leap/soledad/client/_blobs.py
+++ b/client/src/leap/soledad/client/_blobs.py
@@ -18,7 +18,6 @@
Clientside BlobBackend Storage.
"""
-from copy import copy
from urlparse import urljoin
import os
@@ -169,8 +168,10 @@ class BlobManager(object):
fd = doc.blob_fd
# TODO this is a tee really, but ok... could do db and upload
# concurrently. not sure if we'd gain something.
- yield self.local.put(doc.blob_id, fd)
- fd.seek(0)
+ yield self.local.put(doc.blob_id, fd, size=size)
+ # In fact, some kind of pipe is needed here, where each write on db
+ # handle gets forwarded into a write on the connection handle
+ fd = yield self.local.get(doc.blob_id)
yield self._encrypt_and_upload(doc.blob_id, doc.doc_id, doc.rev, fd)
@defer.inlineCallbacks
@@ -274,7 +275,7 @@ class SQLiteBlobBackend(object):
# FIXME should remove this duplication!
# have a look at how treq does cope with closing the handle
# for uploading a file
- producer = FileBodyProducer(copy(blob_fd))
+ producer = FileBodyProducer(blob_fd)
done = yield producer.startProducing(handle)
logger.info("Finished saving blob in local database.")
defer.returnValue(done)