From 463073b3147f9ba4e784e92cc8bec1d74ab0b7f4 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 5 Jul 2017 02:17:38 -0300 Subject: [feature] add blobs as a incoming api backend We started with CouchDB due legacy system relying on it. This commit adds the possibility of adding blobs as a IncomingAPI backend if blobs is enabled on config file. -- Resolves: #8868 --- src/leap/soledad/server/_blobs.py | 1 + src/leap/soledad/server/_incoming.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/leap/soledad/server/_blobs.py b/src/leap/soledad/server/_blobs.py index 87b171fb..f6a8cbc6 100644 --- a/src/leap/soledad/server/_blobs.py +++ b/src/leap/soledad/server/_blobs.py @@ -256,4 +256,5 @@ class BlobsServerState(object): That method is just for compatibility with CouchServerState, so IncomingAPI can change backends. """ + # TODO: deprecate/refactor it as it's here for compatibility. return self.backend diff --git a/src/leap/soledad/server/_incoming.py b/src/leap/soledad/server/_incoming.py index 6fdeb7ae..8d057ae9 100644 --- a/src/leap/soledad/server/_incoming.py +++ b/src/leap/soledad/server/_incoming.py @@ -40,6 +40,10 @@ def _get_backend_from_config(): return CouchServerState(conf['couch_url']) +def uses_legacy(db): + return hasattr(db, 'put_doc') + + class IncomingResource(Resource): isLeaf = True @@ -51,7 +55,7 @@ class IncomingResource(Resource): uuid, doc_id = request.postpath scheme = EncryptionSchemes.PUBKEY db = self.factory.open_database(uuid) - if hasattr(db, 'put_doc'): + if uses_legacy(db): doc = ServerDocument(doc_id) doc.content = self.formatter.format(request.content.read(), scheme) db.put_doc(doc) -- cgit v1.2.3