several bug fixes regarding "content is an array"
This commit is contained in:
parent
5b21104da3
commit
08a79d0e7b
@ -4,7 +4,7 @@
|
|||||||
module.exports = function (Y) {
|
module.exports = function (Y) {
|
||||||
var globalRoom = {
|
var globalRoom = {
|
||||||
users: {},
|
users: {},
|
||||||
buffers: {},
|
buffers: {}, // TODO: reimplement this idea. This does not cover all cases!! Here, you have a queue which is unrealistic (i.e. think about multiple incoming connections)
|
||||||
removeUser: function (user) {
|
removeUser: function (user) {
|
||||||
for (var i in this.users) {
|
for (var i in this.users) {
|
||||||
this.users[i].userLeft(user)
|
this.users[i].userLeft(user)
|
||||||
|
@ -146,8 +146,10 @@ module.exports = function (Y /* :any */) {
|
|||||||
self.gc2 = []
|
self.gc2 = []
|
||||||
for (var i = 0; i < ungc.length; i++) {
|
for (var i = 0; i < ungc.length; i++) {
|
||||||
var op = yield* this.getOperation(ungc[i])
|
var op = yield* this.getOperation(ungc[i])
|
||||||
delete op.gc
|
if (op != null) {
|
||||||
yield* this.setOperation(op)
|
delete op.gc
|
||||||
|
yield* this.setOperation(op)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
@ -386,11 +388,11 @@ module.exports = function (Y /* :any */) {
|
|||||||
let o = Y.utils.copyObject(op)
|
let o = Y.utils.copyObject(op)
|
||||||
yield* t._changed(transaction, o)
|
yield* t._changed(transaction, o)
|
||||||
}
|
}
|
||||||
// Delete if DS says this is actually deleted
|
if (!op.deleted) {
|
||||||
var len = op.content != null ? op.content.length : 1
|
// Delete if DS says this is actually deleted
|
||||||
for (var i = 0; i < len; i++) {
|
var len = op.content != null ? op.content.length : 1
|
||||||
var id = [op.id[0], op.id[1] + i]
|
for (var i = 0; i < len; i++) {
|
||||||
if (!op.deleted) {
|
var id = [op.id[0], op.id[1] + i]
|
||||||
var opIsDeleted = yield* transaction.isDeleted(id)
|
var opIsDeleted = yield* transaction.isDeleted(id)
|
||||||
if (opIsDeleted) {
|
if (opIsDeleted) {
|
||||||
var delop = {
|
var delop = {
|
||||||
|
@ -25,7 +25,7 @@ g.g = g
|
|||||||
|
|
||||||
g.YConcurrency_TestingMode = true
|
g.YConcurrency_TestingMode = true
|
||||||
|
|
||||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 2000
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000
|
||||||
|
|
||||||
g.describeManyTimes = function describeManyTimes (times, name, f) {
|
g.describeManyTimes = function describeManyTimes (times, name, f) {
|
||||||
for (var i = 0; i < times; i++) {
|
for (var i = 0; i < times; i++) {
|
||||||
@ -200,7 +200,7 @@ g.compareAllUsers = async(function * compareAllUsers (users) {
|
|||||||
for (var j in ds) {
|
for (var j in ds) {
|
||||||
var d = ds[j]
|
var d = ds[j]
|
||||||
for (var i = 0; i < d.len; i++) {
|
for (var i = 0; i < d.len; i++) {
|
||||||
var o = yield* this.getOperation([d.id[0], d.id[1] + i])
|
var o = yield* this.getInsertion([d.id[0], d.id[1] + i])
|
||||||
// gc'd or deleted
|
// gc'd or deleted
|
||||||
if (d.gc) {
|
if (d.gc) {
|
||||||
expect(o).toBeFalsy()
|
expect(o).toBeFalsy()
|
||||||
|
@ -68,7 +68,7 @@ module.exports = function (Y/* :any */) {
|
|||||||
if (op.hasOwnProperty('opContent')) {
|
if (op.hasOwnProperty('opContent')) {
|
||||||
e.opContent = op.opContent
|
e.opContent = op.opContent
|
||||||
} else {
|
} else {
|
||||||
e.content = op.content
|
e.content = op.content.slice()
|
||||||
}
|
}
|
||||||
|
|
||||||
return e
|
return e
|
||||||
@ -93,17 +93,21 @@ module.exports = function (Y/* :any */) {
|
|||||||
return ids
|
return ids
|
||||||
},
|
},
|
||||||
getDistanceToOrigin: function * (op) {
|
getDistanceToOrigin: function * (op) {
|
||||||
var d = 0
|
if (op.left == null) {
|
||||||
var o = op
|
return 0
|
||||||
while (!Y.utils.matchesId(o, op.origin)) {
|
} else {
|
||||||
d++
|
var d = 0
|
||||||
if (o.left == null) {
|
var o = yield* this.getInsertion(op.left)
|
||||||
break
|
while (!Y.utils.matchesId(o, op.origin)) {
|
||||||
} else {
|
d++
|
||||||
o = yield* this.getInsertion(o.left)
|
if (o.left == null) {
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
o = yield* this.getInsertion(o.left)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return d
|
||||||
}
|
}
|
||||||
return d
|
|
||||||
},
|
},
|
||||||
/*
|
/*
|
||||||
# $this has to find a unique position between origin and the next known character
|
# $this has to find a unique position between origin and the next known character
|
||||||
|
@ -160,12 +160,20 @@ module.exports = function (Y/* :any */) {
|
|||||||
start.gc = true
|
start.gc = true
|
||||||
start.deleted = true
|
start.deleted = true
|
||||||
yield* this.setOperation(start)
|
yield* this.setOperation(start)
|
||||||
yield* this.markDeleted(start.id, 1)
|
var delLength = start.content != null ? start.content.length : 1
|
||||||
|
yield* this.markDeleted(start.id, delLength)
|
||||||
if (start.opContent != null) {
|
if (start.opContent != null) {
|
||||||
yield* this.deleteOperation(start.opContent)
|
yield* this.deleteOperation(start.opContent)
|
||||||
}
|
}
|
||||||
if (this.store.y.connector.isSynced) {
|
if (this.store.y.connector.isSynced) {
|
||||||
this.store.gc1.push(start.id)
|
this.store.gc1.push(start.id)
|
||||||
|
for (var i = 0; i < delLength; i++) {
|
||||||
|
if (i === 0) {
|
||||||
|
this.store.gc1.push(start.id)
|
||||||
|
} else {
|
||||||
|
this.store.gc1.push([start.id[0], start.id[1] + i])
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
start = start.right
|
start = start.right
|
||||||
@ -386,15 +394,22 @@ module.exports = function (Y/* :any */) {
|
|||||||
*/
|
*/
|
||||||
* garbageCollectAfterSync () {
|
* garbageCollectAfterSync () {
|
||||||
yield* this.os.iterate(this, null, null, function * (op) {
|
yield* this.os.iterate(this, null, null, function * (op) {
|
||||||
|
var opLength = op.content != null ? op.content.length : 1
|
||||||
if (op.gc) {
|
if (op.gc) {
|
||||||
this.store.gc1.push(op.id)
|
for (var i = 0; i < opLength; i++) {
|
||||||
|
if (i === 0) {
|
||||||
|
this.store.gc1.push(op.id)
|
||||||
|
} else {
|
||||||
|
this.store.gc1.push([op.id[0], op.id[1] + i])
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (op.parent != null) {
|
if (op.parent != null) {
|
||||||
var parentDeleted = yield* this.isDeleted(op.parent)
|
var parentDeleted = yield* this.isDeleted(op.parent)
|
||||||
if (parentDeleted) {
|
if (parentDeleted) {
|
||||||
op.gc = true
|
op.gc = true
|
||||||
if (!op.deleted) {
|
if (!op.deleted) {
|
||||||
yield* this.markDeleted(op.id, 1)
|
yield* this.markDeleted(op.id, delLength)
|
||||||
op.deleted = true
|
op.deleted = true
|
||||||
if (op.opContent != null) {
|
if (op.opContent != null) {
|
||||||
yield* this.deleteOperation(op.opContent)
|
yield* this.deleteOperation(op.opContent)
|
||||||
@ -412,7 +427,13 @@ module.exports = function (Y/* :any */) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
yield* this.setOperation(op)
|
yield* this.setOperation(op)
|
||||||
this.store.gc1.push(op.id)
|
for (var i = 0; i < opLength; i++) {
|
||||||
|
if (i === 0) {
|
||||||
|
this.store.gc1.push(op.id)
|
||||||
|
} else {
|
||||||
|
this.store.gc1.push([op.id[0], op.id[1] + i])
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -753,11 +774,15 @@ module.exports = function (Y/* :any */) {
|
|||||||
}
|
}
|
||||||
* getInsertion (id) {
|
* getInsertion (id) {
|
||||||
var ins = yield* this.os.findWithUpperBound(id)
|
var ins = yield* this.os.findWithUpperBound(id)
|
||||||
var len = ins.content != null ? ins.content.length : 1 // in case of opContent
|
if (ins == null) {
|
||||||
if (ins != null && id[0] === ins.id[0] && id[1] < ins.id[1] + len) {
|
|
||||||
return ins
|
|
||||||
} else {
|
|
||||||
return null
|
return null
|
||||||
|
} else {
|
||||||
|
var len = ins.content != null ? ins.content.length : 1 // in case of opContent
|
||||||
|
if (id[0] === ins.id[0] && id[1] < ins.id[1] + len) {
|
||||||
|
return ins
|
||||||
|
} else {
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
* getInsertionCleanStartEnd (id) {
|
* getInsertionCleanStartEnd (id) {
|
||||||
@ -815,9 +840,6 @@ module.exports = function (Y/* :any */) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
* getOperation (id/* :any */)/* :Transaction<any> */ {
|
* getOperation (id/* :any */)/* :Transaction<any> */ {
|
||||||
if (id.length > 2) {
|
|
||||||
id = [id[0], id[1]]
|
|
||||||
}
|
|
||||||
var o = yield* this.os.find(id)
|
var o = yield* this.os.find(id)
|
||||||
if (id[0] !== '_' || o != null) {
|
if (id[0] !== '_' || o != null) {
|
||||||
return o
|
return o
|
||||||
|
Loading…
x
Reference in New Issue
Block a user