Browse files

push up openDbs check and fix actionQueue slice arguments, tests fail

  • Loading branch information...
1 parent e794ce7 commit 7b2e1257eb9969ffdd2d97e2df0ca01043f66666 @substack substack committed Oct 8, 2010
Showing with 19 additions and 19 deletions.
  1. +19 −19 lib/store.js
View
38 lib/store.js
@@ -29,7 +29,13 @@ function Store(opts, cb) {
opts.filename = normalize(opts.filename);
}
-
+
+ if (openDbs[opts.filename]) {
+ var db = openDbs[opts.filename];
+ cb(undefined, db);
+ return;
+ }
+
opts.json = opts.json || false;
self.on('ready', function () {
@@ -40,23 +46,17 @@ function Store(opts, cb) {
delete actionQueue;
});
- if (openDbs[opts.filename]) {
- var db = openDbs[opts.filename];
- cb(undefined, db);
- }
- else {
- var db = new SQLite();
- db.open(opts.filename, function (error) {
- if (error) {
- self.emit('error', error);
- delete openDbs[opts.filename];
- cb(error);
- }
- initStoreTable();
- });
- openDbs[opts.filename] = self;
- }
-
+ var db = new SQLite();
+ db.open(opts.filename, function (error) {
+ if (error) {
+ self.emit('error', error);
+ delete openDbs[opts.filename];
+ cb(error);
+ }
+ initStoreTable();
+ });
+ openDbs[opts.filename] = self;
+
function initStoreTable() {
var hadRow = false;
db.query(
@@ -95,7 +95,7 @@ function Store(opts, cb) {
}
function queue(action, args) {
- actionQueue.push({ action : action, args : [].slice.call([], args) });
+ actionQueue.push({ action : action, args : [].slice.call(args) });
}
self.set = function (key, value, cb) {

0 comments on commit 7b2e125

Please sign in to comment.