summaryrefslogtreecommitdiff
path: root/service/pixelated/support/ext_sync.py
blob: d35eed3e2e4fa67988788c9f373891d25d573ec0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import leap.soledad.client as client
import logging
import urlparse
from leap.soledad.client.events import (
    SOLEDAD_DONE_DATA_SYNC,
    signal
)


def patched_sync(self, defer_decryption=True):
    if self._db:
        try:
            local_gen = self._db.sync(
                urlparse.urljoin(self.server_url, 'user-%s' % self._uuid),
                creds=self._creds, autocreate=False,
                defer_decryption=defer_decryption)
            signal(SOLEDAD_DONE_DATA_SYNC, self._uuid)
            return local_gen
        except Exception as e:
            client.logger.error("Soledad exception when syncing: %s - %s" % (e.__class__.__name__, e.message))


client.Soledad.sync = patched_sync