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.py6
-rw-r--r--src/leap/soledad/client/_db/blobs/sync.py5
2 files changed, 9 insertions, 2 deletions
diff --git a/src/leap/soledad/client/_db/blobs/sql.py b/src/leap/soledad/client/_db/blobs/sql.py
index c9a025a2..c5b0b64b 100644
--- a/src/leap/soledad/client/_db/blobs/sql.py
+++ b/src/leap/soledad/client/_db/blobs/sql.py
@@ -156,9 +156,11 @@ class SQLiteBlobBackend(object):
def update_batch_sync_status(self, blob_id_list, sync_status,
namespace=''):
- insert = 'INSERT INTO sync_state (blob_id, namespace, sync_status)'
+ if not blob_id_list:
+ return
+ insert = 'INSERT or REPLACE INTO sync_state'
first_blob_id, blob_id_list = blob_id_list[0], blob_id_list[1:]
- insert += ' VALUES (?, ?, ?)'
+ insert += ' (blob_id, namespace, sync_status) VALUES (?, ?, ?)'
values = (first_blob_id, namespace, sync_status)
for blob_id in blob_id_list:
insert += ', (?, ?, ?)'
diff --git a/src/leap/soledad/client/_db/blobs/sync.py b/src/leap/soledad/client/_db/blobs/sync.py
index 838b87e5..bfdc5fbe 100644
--- a/src/leap/soledad/client/_db/blobs/sync.py
+++ b/src/leap/soledad/client/_db/blobs/sync.py
@@ -62,10 +62,15 @@ class BlobsSynchronizer(object):
d2 = self.local_list(namespace=namespace)
remote_list, local_list = yield defer.gatherResults([d1, d2])
pending_download_ids = tuple(set(remote_list) - set(local_list))
+ pending_upload_ids = tuple(set(local_list) - set(remote_list))
yield self.local.update_batch_sync_status(
pending_download_ids,
SyncStatus.PENDING_DOWNLOAD,
namespace=namespace)
+ yield self.local.update_batch_sync_status(
+ pending_upload_ids,
+ SyncStatus.PENDING_UPLOAD,
+ namespace=namespace)
@defer.inlineCallbacks
def send_missing(self, namespace=''):