gridfs-locks
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -0,1 +1,5 @@ | ||
### 1.3.2 | ||
- Fixed race issue when mutliple clients simultaneously create new LockCollections backed by the same mongodb server. | ||
### 1.3.1 | ||
@@ -2,0 +6,0 @@ |
29
index.js
@@ -23,10 +23,10 @@ /*********************************************************************** | ||
var isMongoDriver20 = function (collection, callback) { | ||
collection.insert({testdoc: true}, function (err, res) { | ||
if (err) { return callback(err); } | ||
collection.findAndRemove({testdoc: true}, [['testdoc', 1]], function (err, res) { | ||
if (err) { return callback(err); } | ||
callback(null, (res.ok === 1)); | ||
}); | ||
}); | ||
var isMongoDriver20 = function (db) { | ||
// This is probably not the best test, but officially I'm not sure | ||
// how to distinguish which driver is being used. | ||
if (db.hasOwnProperty('s')) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}; | ||
@@ -74,15 +74,10 @@ | ||
self._isMongo26 = is26; | ||
self._isMongoDriver20 = isMongoDriver20(db); | ||
db.collection(collectionName, function(err, collection) { | ||
if (err) { return emitError(self, err); } | ||
isMongoDriver20(collection, function (err, is20) { | ||
collection.ensureIndex([['files_id', 1]], {unique:true}, function(err, index) { | ||
if (err) { return emitError(self, err); } | ||
self._isMongoDriver20 = is20; | ||
// Ensure unique files_id so there can only be one lock doc per file | ||
collection.ensureIndex([['files_id', 1]], {unique:true}, function(err, index) { | ||
if (err) { return emitError(self, err); } | ||
self.collection = collection; | ||
self.emit('ready'); | ||
}); | ||
self.collection = collection; | ||
self.emit('ready'); | ||
}); | ||
@@ -89,0 +84,0 @@ }); |
{ | ||
"name": "gridfs-locks", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "Distributed read/write locking based on MongoDB, designed to make GridFS safe for concurrent access", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"mongodb": "2.0.19", | ||
"mongodb": "2.0.21", | ||
"coffee-script": "*", | ||
@@ -11,0 +11,0 @@ "mocha": "*" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89738
744