summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-10-31 06:15:06 -0300
committerVictor Shyba <victor1984@riseup.net>2017-10-31 06:15:06 -0300
commitc8234da89b198064f1d1f14bec6811c0883e705c (patch)
tree78fbf8fbb0ca149897acf2cfb6c5b4c753cd9cf5 /src/leap
parent72956174187fa2fccbb060d04d4809797657e029 (diff)
[feature] add sync progress attribute
--Resolves: #8848
Diffstat (limited to 'src/leap')
-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()