summaryrefslogtreecommitdiff
path: root/src/leap/soledad/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/soledad/client')
-rw-r--r--src/leap/soledad/client/_db/blobs/sql.py14
-rw-r--r--src/leap/soledad/client/_db/blobs/sync.py4
2 files changed, 18 insertions, 0 deletions
diff --git a/src/leap/soledad/client/_db/blobs/sql.py b/src/leap/soledad/client/_db/blobs/sql.py
index 72fc250b..e81580a7 100644
--- a/src/leap/soledad/client/_db/blobs/sql.py
+++ b/src/leap/soledad/client/_db/blobs/sql.py
@@ -105,6 +105,20 @@ class SQLiteBlobBackend(object):
defer.returnValue((result[0][0], result[0][1]))
@defer.inlineCallbacks
+ def get_sync_progress(self):
+ query = 'SELECT sync_status, COUNT(sync_status) FROM sync_state'
+ query += ' GROUP BY sync_status'
+
+ def by_value(value):
+ statuses = SyncStatus.__dict__.items()
+ return filter(lambda x: x[1] == value, statuses)[0][0]
+ result = yield self.dbpool.runQuery(query)
+ if result:
+ defer.returnValue(dict([(by_value(r[0]), r[1]) for r in result]))
+ else:
+ defer.returnValue([])
+
+ @defer.inlineCallbacks
def list(self, namespace=''):
query = 'select blob_id from blobs where namespace = ?'
values = (namespace,)
diff --git a/src/leap/soledad/client/_db/blobs/sync.py b/src/leap/soledad/client/_db/blobs/sync.py
index ee10443d..d47033b2 100644
--- a/src/leap/soledad/client/_db/blobs/sync.py
+++ b/src/leap/soledad/client/_db/blobs/sync.py
@@ -126,3 +126,7 @@ class BlobsSynchronizer(object):
yield self.send_missing(namespace)
except defer.FirstError as e:
e.subFailure.raiseException()
+
+ @property
+ def sync_progress(self):
+ return self.local.get_sync_progress()