summaryrefslogtreecommitdiff
path: root/src/leap/soledad/common/README.txt
blob: 0a252650989640f7aaa4174e8f9bc3b31a153db1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Soledad common package
======================

This package contains Soledad bits used by both server and client.

Couch L2DB Backend
------------------

L2DB backends rely on some atomic operations that modify documents contents
and metadata (conflicts, transaction ids and indexes). The only atomic
operation in Couch is a document put, so every u1db atomic operation has to be
mapped to a couch document put.

The atomic operations in the U1DB SQLite reference backend implementation may
be identified by the use of a context manager to access the underlying
database. A listing of the methods involved in each atomic operation are
depiced below. The top-level elements correpond to the atomic operations that
have to be mapped, and items on deeper levels of the list have to be
implemented in a way that all changes will be pushed with just one operation.

    * _set_replica_uid
    * put_doc:
        * _get_doc
        * _put_and_update_indexes
            * insert/update the document
            * insert into transaction log
    * delete_doc
        * _get_doc
        * _put_and_update_indexes
    * get_doc_conflicts
        * _get_conflicts
    * _set_replica_gen_and_trans_id
        * _do_set_replica_gen_and_trans_id
    * _put_doc_if_newer
        * _get_doc
        * _validate_source (**)
            * _get_replica_gen_and_trans_id
        * cases:
            * is newer:
                * _prune_conflicts (**)
                    * _has_conflicts
                    * _delete_conflicts
                * _put_and_update_indexes
            * same content as:
                * _put_and_update_indexes
            * conflicted:
                * _force_doc_sync_conflict
                    * _prune_conflicts
                    * _add_conflict
                    * _put_and_update_indexes
        * _do_set_replica_gen_and_trans_id
    * resolve_doc
        * _get_doc
        * cases:
            * doc is superseded
                * _put_and_update_indexes
            * else
                * _add_conflict
        * _delete_conflicts
    * delete_index
    * create_index

Notes:

  * Currently, the couch backend does not implement indexing, so what is
    depicted as `_put_and_update_indexes` above will be found as `_put_doc` in
    the backend.

  * Conflict updates are part of document put using couch update functions,
    and as such are part of the same atomic operation as document put.