From 74c881bb5b0b5bf18fc44827cc568d6d17d3f329 Mon Sep 17 00:00:00 2001 From: Kevin Jahns <kevin.jahns@rwth-aachen.de> Date: Mon, 1 Aug 2016 16:52:02 +0200 Subject: [PATCH] Fixed bug that only occurs in persistent databases (setOperation was not called). --- src/Connectors/Test.js | 2 +- src/SpecHelper.js | 5 ++++- src/Transaction.js | 5 +---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Connectors/Test.js b/src/Connectors/Test.js index 9492eb27..b78ce7b6 100644 --- a/src/Connectors/Test.js +++ b/src/Connectors/Test.js @@ -4,7 +4,7 @@ module.exports = function (Y) { var globalRoom = { users: {}, - 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) + buffers: {}, removeUser: function (user) { for (var i in this.users) { this.users[i].userLeft(user) diff --git a/src/SpecHelper.js b/src/SpecHelper.js index b014c9d6..4d09d25f 100644 --- a/src/SpecHelper.js +++ b/src/SpecHelper.js @@ -11,6 +11,7 @@ require('../../y-memory/src/Memory.js')(Y) require('../../y-array/src/Array.js')(Y) require('../../y-map/src/Map.js')(Y) require('../../y-indexeddb/src/IndexedDB.js')(Y) +require('../../y-leveldb/src/LevelDB.js')(Y) module.exports = Y var g @@ -28,7 +29,7 @@ Math.seedrandom = require('seedrandom') g.generateRandomSeed = function generateRandomSeed() { var seed - if (window.location.hash.length > 1) { + if (typeof window != 'undefined' && window.location.hash.length > 1) { seed = window.location.hash.slice(1) // first character is the hash! console.warn('Using random seed that was specified in the url!') } else { @@ -74,6 +75,8 @@ g.wait = wait g.databases = ['memory'] if (typeof window !== 'undefined') { g.databases.push('indexeddb') +} else { + g.databases.push('leveldb') } /* returns a random element of o. diff --git a/src/Transaction.js b/src/Transaction.js index 461db13b..1997a34d 100644 --- a/src/Transaction.js +++ b/src/Transaction.js @@ -502,6 +502,7 @@ module.exports = function (Y/* :any */) { if (o.right != null) { var right = yield* this.getOperation(o.right) right.left = o.left + yield* this.setOperation(right) if (o.originOf != null && o.originOf.length > 0) { // find new origin of right ops @@ -568,10 +569,6 @@ module.exports = function (Y/* :any */) { } // we don't need to set right here, because // right should be in o.originOf => it is set it the previous for loop - } else { - // we didn't need to reset the origin of right - // so we have to set right here - yield* this.setOperation(right) } } // o may originate in another operation. -- GitLab