[Pkg-javascript-commits] [node-leveldown] 195/492: fix put/batch bug in WriteStream#_process()

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:13:58 UTC 2014


This is an automated email from the git hooks/post-receive script.

andrewrk-guest pushed a commit to annotated tag rocksdb-0.10.1
in repository node-leveldown.

commit 132cc1a274d9ffecbcc5589a5e438f7d5cc2dc12
Author: Lars-Magnus Skog <lars.magnus.skog at gmail.com>
Date:   Sun Feb 3 04:08:03 2013 +0100

    fix put/batch bug in WriteStream#_process()
---
 lib/write-stream.js | 40 ++++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/lib/write-stream.js b/lib/write-stream.js
index 63106b2..fe8ad10 100644
--- a/lib/write-stream.js
+++ b/lib/write-stream.js
@@ -1,6 +1,7 @@
 /* Copyright (c) 2012-2013 LevelUP contributors
  * See list at <https://github.com/rvagg/node-levelup#contributing>
- * MIT +no-false-attribs License <https://github.com/rvagg/node-levelup/blob/master/LICENSE>
+ * MIT +no-false-attribs License
+ * <https://github.com/rvagg/node-levelup/blob/master/LICENSE>
  */
 
 var Stream       = require('stream').Stream
@@ -44,7 +45,8 @@ WriteStream.prototype.write = function (data) {
   this._buffer.push(data)
   if (this._status != 'init')
     this._processDelayed()
-  if (this._options.maxBufferLength && this._buffer.length > this._options.maxBufferLength) {
+  if (this._options.maxBufferLength &&
+      this._buffer.length > this._options.maxBufferLength) {
     this._writeBlock = true
     return false
   }
@@ -82,18 +84,20 @@ WriteStream.prototype._processDelayed = function() {
 }
 
 WriteStream.prototype._process = function() {
-  var cb = function (err) {
-    if (!this.writable)
-      return
-    if (this._status != 'closed')
-      this._status = 'ready'
-    if (err) {
-      this.writable = false
-      return this.emit('error', err)
-    }
-    this._process()
-  }.bind(this)
-  , buffer, entry
+  var buffer
+    , entry
+
+    , cb = function (err) {
+        if (!this.writable)
+          return
+        if (this._status != 'closed')
+          this._status = 'ready'
+        if (err) {
+          this.writable = false
+          return this.emit('error', err)
+        }
+        this._process()
+      }.bind(this)
 
   if (this._status != 'ready' && this.writable) {
     if (this._buffer.length && this._status != 'closed')
@@ -105,8 +109,8 @@ WriteStream.prototype._process = function() {
     this._status = 'writing'
     buffer = this._buffer
     this._buffer = []
-    if (this._buffer.length == 1) {
-      entry = this._buffer.pop()
+    if (buffer.length == 1) {
+      entry = buffer.pop()
       if (entry.key !== undefined && entry.value !== undefined)
         this._db.put(entry.key, entry.value, cb)
     } else {
@@ -124,7 +128,6 @@ WriteStream.prototype._process = function() {
     this._status = 'closed'
     this.writable = false
     this.emit('close')
-    return
   }
 }
 
@@ -137,7 +140,8 @@ WriteStream.prototype._write = function (entry) {
       this.writable = false
       return this.emit('error', err)
     }
-    if (this._options.fstreamRoot && key.indexOf(this._options.fstreamRoot) > -1)
+    if (this._options.fstreamRoot &&
+        key.indexOf(this._options.fstreamRoot) > -1)
       key = key.substr(this._options.fstreamRoot.length + 1)
     this.write({ key: key, value: data })
   }.bind(this)))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-leveldown.git



More information about the Pkg-javascript-commits mailing list