diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-06-26 10:24:58 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-06-26 10:24:58 +0200 |
commit | da4b74e593f1b1262e83824cc499bd855f1b4e3e (patch) | |
tree | 95b56aa073a85022c4218375e1c788894f01c2b6 /common/storage/entitystore.h | |
parent | 121c3bc96a273790414ae114082053cb649fc49a (diff) | |
download | sink-da4b74e593f1b1262e83824cc499bd855f1b4e3e.tar.gz sink-da4b74e593f1b1262e83824cc499bd855f1b4e3e.zip |
Avoid overwriting local changes with remote modifications.
The case we ran into is the following:
* Fetching the full payload and marking all messages of a thread as read
happens simultaneously.
* The local modification to mark as read gets immediately overwritten
when the full payload arrives.
* Eventually the modification gets replayed to the server though (and
the reversal isn't because coming from the source), so on next sync the
situation fixes itself.
To be able to improve this we try to protect local modifications in that
properties that have been modified since baseRevision (which currently
isn't, but should be equal to the last to the server replayed revision)
are not overwritten. This conflict resolution strategy thus always
prefers local modifications. baseRevision is currently set to the
current maximum revision of the store at the time when the resource
creates the modification.
Diffstat (limited to 'common/storage/entitystore.h')
-rw-r--r-- | common/storage/entitystore.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/common/storage/entitystore.h b/common/storage/entitystore.h index ffa70b9..69de76c 100644 --- a/common/storage/entitystore.h +++ b/common/storage/entitystore.h | |||
@@ -49,7 +49,7 @@ public: | |||
49 | bool modify(const QByteArray &type, const ApplicationDomainType ¤t, ApplicationDomainType newEntity, bool replayToSource); | 49 | bool modify(const QByteArray &type, const ApplicationDomainType ¤t, ApplicationDomainType newEntity, bool replayToSource); |
50 | bool remove(const QByteArray &type, const ApplicationDomainType ¤t, bool replayToSource); | 50 | bool remove(const QByteArray &type, const ApplicationDomainType ¤t, bool replayToSource); |
51 | bool cleanupRevisions(qint64 revision); | 51 | bool cleanupRevisions(qint64 revision); |
52 | ApplicationDomainType applyDiff(const QByteArray &type, const ApplicationDomainType ¤t, const ApplicationDomainType &diff, const QByteArrayList &deletions) const; | 52 | ApplicationDomainType applyDiff(const QByteArray &type, const ApplicationDomainType ¤t, const ApplicationDomainType &diff, const QByteArrayList &deletions, const QSet<QByteArray> &excludeProperties = {}) const; |
53 | 53 | ||
54 | void startTransaction(Sink::Storage::DataStore::AccessMode); | 54 | void startTransaction(Sink::Storage::DataStore::AccessMode); |
55 | void commitTransaction(); | 55 | void commitTransaction(); |
@@ -122,6 +122,8 @@ public: | |||
122 | ///Db contains entity and entity is not yet removed | 122 | ///Db contains entity and entity is not yet removed |
123 | bool exists(const QByteArray &type, const QByteArray &uid); | 123 | bool exists(const QByteArray &type, const QByteArray &uid); |
124 | 124 | ||
125 | void readRevisions(const QByteArray &type, const QByteArray &uid, qint64 baseRevision, const std::function<void(const QByteArray &uid, qint64 revision, const EntityBuffer &entity)> callback); | ||
126 | |||
125 | qint64 maxRevision(); | 127 | qint64 maxRevision(); |
126 | 128 | ||
127 | Sink::Log::Context logContext() const; | 129 | Sink::Log::Context logContext() const; |