diff options
author | Victor Shyba <victor1984@riseup.net> | 2017-12-14 14:27:02 -0300 |
---|---|---|
committer | Victor Shyba <victor1984@riseup.net> | 2017-12-22 13:51:27 -0300 |
commit | 390703b41e7c46e0dcb14c14d7a8aba09483c7db (patch) | |
tree | c4226d5f80dff93e0bb7fe8f50e678c78c284f23 /src/leap/soledad | |
parent | 7d76e9db4c864aa4b70989dcddbcb616b3f4c0f0 (diff) |
[feature] get_size_list for listing blobs sizes
Diffstat (limited to 'src/leap/soledad')
-rw-r--r-- | src/leap/soledad/client/_db/blobs/sql.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/leap/soledad/client/_db/blobs/sql.py b/src/leap/soledad/client/_db/blobs/sql.py index 6b92c503..a192ae1e 100644 --- a/src/leap/soledad/client/_db/blobs/sql.py +++ b/src/leap/soledad/client/_db/blobs/sql.py @@ -218,6 +218,20 @@ class SQLiteBlobBackend(object): defer.returnValue([]) @defer.inlineCallbacks + def get_size_list(self, blob_ids, namespace=''): + query = 'SELECT BLOB_ID, LENGTH(PAYLOAD) FROM BLOBS WHERE BLOB_ID IN ' + query += ('(%s)' % ', '.join(['?' for _ in blob_ids])) + query += ' AND NAMESPACE = ? ORDER BY BLOB_ID' + values = tuple(blob_ids) + (namespace,) + results = yield self.dbpool.runQuery(query, values) + if results: + results = dict([(result[0], result[1]) for result in results]) + results = [(blob_id, results[blob_id]) for blob_id in blob_ids] + defer.returnValue(results) + else: + defer.returnValue([]) + + @defer.inlineCallbacks def exists(self, blob_id, namespace=''): query = 'SELECT blob_id from blobs WHERE blob_id = ? AND namespace= ?' result = yield self.dbpool.runQuery(query, (blob_id, namespace,)) |