Skip to content
Browse files

move openDbs stuff down there and it fixes this .get test error that …

…I have
  • Loading branch information...
1 parent 0b9c259 commit 52e06cabc8123dc8f6fa000855ffa07a7317e6d0 @pkrumins committed
Showing with 20 additions and 18 deletions.
  1. +20 −18 lib/store.js
View
38 lib/store.js
@@ -28,13 +28,7 @@ function Store(opts, cb) {
opts.filename = process.cwd() + '/' + opts.filename;
opts.filename = normalize(opts.filename);
-
- if (openDbs[opts.filename]) {
- var db = openDbs[opts.filename];
- cb(undefined, db);
- return;
- }
- }
+ }
opts.json = opts.json || false;
@@ -45,17 +39,6 @@ function Store(opts, cb) {
});
delete actionQueue;
});
-
- 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;
@@ -261,5 +244,24 @@ function Store(opts, cb) {
}
);
}
+
+ if (openDbs[opts.filename]) {
+ var db = openDbs[opts.filename];
+ cb(undefined, db);
+ return;
+ }
+ else {
+ var db = new SQLite();
+ db.open(opts.filename, function (error) {
+ if (error) {
+ self.emit('error', error);
+ delete openDbs[opts.filename];
+ cb(error);
+ }
+ initStoreTable();
+ });
+ if (opts.filename != ':memory:')
+ openDbs[opts.filename] = self;
+ }
};

0 comments on commit 52e06ca

Please sign in to comment.
Something went wrong with that request. Please try again.