From 638c575dfc3832ee730efb136881f64b938124da Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Tue, 29 Sep 2015 01:01:04 +0200 Subject: [PATCH] fixed some consistency bugs. new method seems to work well, it still has problems though --- gulpfile.js | 2 +- src/OperationStore.js | 7 ++++++- src/OperationStores/Memory.js | 2 +- src/Types/Array.spec.js | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 9ec7ef1a..317ac0a8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -87,7 +87,7 @@ var files = { src: polyfills.concat(concatOrder.map(function (f) { return 'src/' + f })), - test: ['Helper.spec.js'].concat(concatOrder.map(function (f) { + test: ['build/Helper.spec.js'].concat(concatOrder.map(function (f) { return 'build/' + f }).concat(['build/**/*.spec.js'])) } diff --git a/src/OperationStore.js b/src/OperationStore.js index 2a17055c..6bbba9a3 100644 --- a/src/OperationStore.js +++ b/src/OperationStore.js @@ -167,6 +167,11 @@ class AbstractTransaction { } * garbageCollectOperation (id) { var o = yield* this.getOperation(id) + + if (o == null) { + return + } + if (!o.deleted) { yield* this.deleteOperation(id) o = yield* this.getOperation(id) @@ -422,7 +427,7 @@ class AbstractOperationStore { } else { while (op != null) { var state = yield* this.getState(op.id[0]) - if (op.id[1] === state.clock || (op.id[1] < state.clock && (yield* this.getOperation(op.id)) == null)) { + if (op.id[1] === state.clock) { // either its a new operation (1. case), or it is an operation that was deleted, but is not yet in the OS if (op.id[1] === state.clock) { state.clock++ diff --git a/src/OperationStores/Memory.js b/src/OperationStores/Memory.js index 5ba6b735..60d709c4 100644 --- a/src/OperationStores/Memory.js +++ b/src/OperationStores/Memory.js @@ -110,7 +110,7 @@ Y.Memory = (function () { } * checkDeleteStoreForState (state) { var n = this.ds.findNodeWithUpperBound([state.user, state.clock]) - if (n !== null && n.val.id[0] === state.user) { + if (n !== null && n.val.id[0] === state.user && n.val.gc) { state.clock = Math.max(state.clock, n.val.id[1] + n.val.len) } } diff --git a/src/Types/Array.spec.js b/src/Types/Array.spec.js index 97392c3b..7d2bf6a1 100644 --- a/src/Types/Array.spec.js +++ b/src/Types/Array.spec.js @@ -1,7 +1,7 @@ /* global createUsers, wait, Y, compareAllUsers, getRandomNumber, applyRandomTransactions, async, garbageCollectAllUsers, describeManyTimes */ /* eslint-env browser,jasmine */ -var numberOfYArrayTests = 50 +var numberOfYArrayTests = 10 var repeatArrayTests = 300 describe('Array Type', function () {