Skip to content

Commit f781c40

Browse files
committed
Ensured new database connections start by changing journal mode to WAL before anything else.
1 parent 6c130d3 commit f781c40

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

www/SQLitePlugin.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,24 @@
201201
_this.openDBs[_this.dbname].state = DB_STATE_OPEN;
202202
_this.openDBs[_this.dbname].connections.push(connectionName);
203203
}
204+
205+
var callSuccessAndStartTransaction = function () {
206+
if (!!success) {
207+
success(_this);
208+
}
209+
txLock = txLocks[_this.dbname];
210+
if (!!txLock && txLock.queue.length > 0) {
211+
_this.startNextTransaction();
212+
}
213+
};
214+
204215
if (maxConnections > 1) {
205216
// Otherwise readers will be blocked by writers
206-
_this.executeSql('PRAGMA journal_mode = WAL;', []);
207-
}
208-
if (!!success) {
209-
success(_this);
210-
}
211-
txLock = txLocks[_this.dbname];
212-
if (!!txLock && txLock.queue.length > 0) {
213-
_this.startNextTransaction();
217+
_this.executeSql('PRAGMA journal_mode = WAL;', [], callSuccessAndStartTransaction);
218+
} else {
219+
callSuccessAndStartTransaction();
214220
}
221+
215222
};
216223
};
217224
})(this);

0 commit comments

Comments
 (0)