Hello,
i’m using android couchbase lite. I have an android client which is in pull replication with a sync_gateway.
It may happen that during pull, conflicts are created on documents. I would like to solve conflicts during the replication time, so i thought i could do something like this:
pull.addChangeListener(new Replication.ChangeListener() {
@Override
public void changed(Replication.ChangeEvent event) {
// will be called back when the pull replication status changes
if (event.getSource().getStatus() != Replication.ReplicationStatus.REPLICATION_OFFLINE) {
List<String> docIds = event.getSource().getDocIds();
if (docIds != null) {
for (String docId : docIds) {
Document doc = database.getDocument(docId);
List<SavedRevision> conflicts = null;
try {
conflicts = doc.getConflictingRevisions();
} catch (CouchbaseLiteException e) {
e.printStackTrace();
L.e("Errore mentre recupero le versioni in conflitto", e);
}
//here i would solve the conflicts but i never reach this point as docIds is always null
}
}
}
}
});
The problem is that event.getSource().getDocIds()
is always null.
Is there a way to intercept all the documents that are pulled and then solve the conflicts at that moment?
Here it is suggested to solve conflict at document read-time but i would like to avoid that and solve it immediately when the conflict is generated (that is at pull time).
I also know i could add a document listener as explained here but i may have up to 80000 documents so i don’t know if it is good from a performance view but more important, documents will be created on server side and transferred to mobile via pull replication so i don’t know how to add the listener if i don’t know that the document has been created.