fixed several sync issues
This commit is contained in:
parent
93c23ddc09
commit
cd0cddaf35
@ -144,11 +144,6 @@ module.exports = function (Y/* :any */) {
|
||||
this.whenSyncedListeners.push(f)
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
returns false, if there is no sync target
|
||||
true otherwise
|
||||
*/
|
||||
findNextSyncTarget () {
|
||||
if (this.y == null) {
|
||||
debugger
|
||||
@ -179,16 +174,20 @@ module.exports = function (Y/* :any */) {
|
||||
})
|
||||
})
|
||||
} else {
|
||||
this.y.db.requestTransaction(function *() {
|
||||
// it is crucial that isSynced is set at the time garbageCollectAfterSync is called
|
||||
conn.isSynced = true
|
||||
yield* this.garbageCollectAfterSync()
|
||||
// call whensynced listeners
|
||||
for (var f of conn.whenSyncedListeners) {
|
||||
f()
|
||||
}
|
||||
conn.whenSyncedListeners = []
|
||||
})
|
||||
if (!conn.isSynced) {
|
||||
this.y.db.requestTransaction(function *() {
|
||||
if (!conn.isSynced) {
|
||||
// it is crucial that isSynced is set at the time garbageCollectAfterSync is called
|
||||
conn.isSynced = true
|
||||
yield* this.garbageCollectAfterSync()
|
||||
// call whensynced listeners
|
||||
for (var f of conn.whenSyncedListeners) {
|
||||
f()
|
||||
}
|
||||
conn.whenSyncedListeners = []
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
send (uid, message) {
|
||||
|
@ -85,7 +85,7 @@ module.exports = function (Y /* :any */) {
|
||||
function garbageCollect () {
|
||||
return os.whenTransactionsFinished().then(function () {
|
||||
if (os.gc1.length > 0 || os.gc2.length > 0) {
|
||||
if (!os.y.isSynced) {
|
||||
if (!os.y.connector.isSynced) {
|
||||
console.warn('gc should be empty when not synced!')
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
@ -155,7 +155,7 @@ module.exports = function (Y /* :any */) {
|
||||
clearInterval(this.repairCheckIntervalHandler)
|
||||
}
|
||||
queueGarbageCollector (id) {
|
||||
if (this.y.isSynced && this.gc) {
|
||||
if (this.y.connector.isSynced && this.gc) {
|
||||
this.gc1.push(id)
|
||||
}
|
||||
}
|
||||
@ -221,7 +221,7 @@ module.exports = function (Y /* :any */) {
|
||||
op.gc == null &&
|
||||
op.deleted === true &&
|
||||
this.store.gc &&
|
||||
this.store.y.isSynced
|
||||
this.store.y.connector.isSynced
|
||||
) {
|
||||
var gc = false
|
||||
if (left != null && left.deleted === true) {
|
||||
|
@ -96,7 +96,7 @@ module.exports = function (Y/* :any */) {
|
||||
send.push(Y.Struct[op.struct].encode(op))
|
||||
}
|
||||
}
|
||||
if (!this.store.y.connector.isDisconnected() && send.length > 0) { // TODO: && !this.store.forwardAppliedOperations (but then i don't send delete ops)
|
||||
if (this.store.y.connector.isSynced && send.length > 0) { // TODO: && !this.store.forwardAppliedOperations (but then i don't send delete ops)
|
||||
// is connected, and this is not going to be send in addOperation
|
||||
this.store.y.connector.broadcastOps(send)
|
||||
}
|
||||
@ -714,7 +714,7 @@ module.exports = function (Y/* :any */) {
|
||||
}
|
||||
* addOperation (op) {
|
||||
yield* this.os.put(op)
|
||||
if (!this.store.y.connector.isDisconnected() && this.store.forwardAppliedOperations && typeof op.id[1] !== 'string') {
|
||||
if (this.store.y.connector.isSynced && this.store.forwardAppliedOperations && typeof op.id[1] !== 'string') {
|
||||
// is connected, and this is not going to be send in addOperation
|
||||
this.store.y.connector.broadcastOps([op])
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user