Skip to content

Commit 62e88e4

Browse files
committed
Fixed usage of legacy buffer write operations
1 parent 0312076 commit 62e88e4

File tree

5 files changed

+127
-127
lines changed

5 files changed

+127
-127
lines changed

lib/cursor.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,8 @@ Cursor.prototype._read = function(n) {
773773
}
774774

775775
// Emit end event
776-
return self.emit('end');
776+
self.emit('end');
777+
return self.emit('finish');
777778
}
778779

779780
// If we provided a transformation method

lib/gridfs/chunk.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ var Chunk = function(file, mongoObject, writeConcern) {
3232
if(mongoObjectFinal.data == null) {
3333
} else if(typeof mongoObjectFinal.data == "string") {
3434
var buffer = new Buffer(mongoObjectFinal.data.length);
35-
buffer.write(mongoObjectFinal.data, 0, 'binary');
35+
buffer.write(mongoObjectFinal.data, 0, mongoObjectFinal.data.length, 'binary');
3636
this.data = new Binary(buffer);
3737
} else if(Array.isArray(mongoObjectFinal.data)) {
3838
var buffer = new Buffer(mongoObjectFinal.data.length);
39-
buffer.write(mongoObjectFinal.data.join(''), 0, 'binary');
39+
var data = mongoObjectFinal.data.join('');
40+
buffer.write(data, 0, data.length, 'binary');
4041
this.data = new Binary(buffer);
4142
} else if(mongoObjectFinal.data._bsontype === 'Binary') {
4243
this.data = mongoObjectFinal.data;
@@ -58,7 +59,7 @@ var Chunk = function(file, mongoObject, writeConcern) {
5859
* will contain a reference to this object.
5960
*/
6061
Chunk.prototype.write = function(data, callback) {
61-
this.data.write(data, this.internalPosition);
62+
this.data.write(data, this.internalPosition, data.length, 'binary');
6263
this.internalPosition = this.data.length();
6364
if(callback != null) return callback(null, this);
6465
return this;

lib/gridfs/grid_store.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,8 +1085,8 @@ GridStore.exist = function(db, fileIdObject, rootCollection, options, callback)
10851085
: {'_id':fileIdObject}; // Attempt to locate file
10861086

10871087
// We have a specific query
1088-
if(fileIdObject != null
1089-
&& typeof fileIdObject == 'object'
1088+
if(fileIdObject != null
1089+
&& typeof fileIdObject == 'object'
10901090
&& Object.prototype.toString.call(fileIdObject) != '[object RegExp]') {
10911091
query = fileIdObject;
10921092
}
@@ -1365,7 +1365,7 @@ GridStoreStream.prototype.pipe = function(destination) {
13651365
});
13661366
} else {
13671367
self.totalBytesToRead = self.gs.length - self.gs.position;
1368-
self._pipe.apply(self, [destination]);
1368+
self._pipe.apply(self, [destination]);
13691369
}
13701370
}
13711371

@@ -1393,7 +1393,7 @@ GridStoreStream.prototype._read = function(n) {
13931393
if(self.totalBytesToRead <= 0) {
13941394
self.endCalled = true;
13951395
}
1396-
});
1396+
});
13971397
}
13981398

13991399
// Set read length

test/functional/collection_tests.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ exports.shouldAccessToCollections = {
8686
if(collection.collectionName == "does_not_exist") found_does_not_exist = true;
8787
});
8888

89-
console.dir(collections)
90-
9189
test.ok(found_spiderman);
9290
test.ok(found_mario);
9391
test.ok(!found_does_not_exist);

0 commit comments

Comments
 (0)