Use Zotero.DBConnection instance everywhere instead of Zotero.DB
Fixes #1141
This commit is contained in:
parent
5523dd5c37
commit
5d67656ea8
1 changed files with 15 additions and 19 deletions
|
@ -345,7 +345,7 @@ Zotero.DBConnection.prototype.rollbackAllTransactions = function () {
|
||||||
|
|
||||||
|
|
||||||
Zotero.DBConnection.prototype.getColumns = function (table) {
|
Zotero.DBConnection.prototype.getColumns = function (table) {
|
||||||
return Zotero.DB.queryAsync("PRAGMA table_info(" + table + ")")
|
return this.queryAsync("PRAGMA table_info(" + table + ")")
|
||||||
.then(function (rows) {
|
.then(function (rows) {
|
||||||
return rows.map(row => row.name);
|
return rows.map(row => row.name);
|
||||||
})
|
})
|
||||||
|
@ -468,7 +468,7 @@ Zotero.DBConnection.prototype.executeTransaction = Zotero.Promise.coroutine(func
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while (this._transactionID) {
|
while (this._transactionID) {
|
||||||
yield Zotero.DB.waitForTransaction(id).timeout(options.waitTimeout || 10000);
|
yield this.waitForTransaction(id).timeout(options.waitTimeout || 10000);
|
||||||
}
|
}
|
||||||
startedTransaction = true;
|
startedTransaction = true;
|
||||||
this._transactionID = id;
|
this._transactionID = id;
|
||||||
|
@ -499,7 +499,7 @@ Zotero.DBConnection.prototype.executeTransaction = Zotero.Promise.coroutine(func
|
||||||
|
|
||||||
if (options.vacuumOnCommit) {
|
if (options.vacuumOnCommit) {
|
||||||
Zotero.debug('Vacuuming database');
|
Zotero.debug('Vacuuming database');
|
||||||
yield Zotero.DB.queryAsync('VACUUM');
|
yield this.queryAsync('VACUUM');
|
||||||
}
|
}
|
||||||
|
|
||||||
this._transactionID = null;
|
this._transactionID = null;
|
||||||
|
@ -816,16 +816,12 @@ Zotero.DBConnection.prototype.logQuery = function (sql, params = [], options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Zotero.DBConnection.prototype.tableExists = function (table) {
|
Zotero.DBConnection.prototype.tableExists = Zotero.Promise.coroutine(function* (table) {
|
||||||
return this._getConnectionAsync()
|
yield this._getConnectionAsync();
|
||||||
.then(function () {
|
var sql = "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND tbl_name=?";
|
||||||
var sql = "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND tbl_name=?";
|
var count = yield this.valueQueryAsync(sql, [table]);
|
||||||
return Zotero.DB.valueQueryAsync(sql, [table]);
|
return !!count;
|
||||||
})
|
});
|
||||||
.then(function (count) {
|
|
||||||
return !!count;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -855,7 +851,7 @@ Zotero.DBConnection.prototype.executeSQLFile = Zotero.Promise.coroutine(function
|
||||||
|
|
||||||
var statement;
|
var statement;
|
||||||
while (statement = statements.shift()) {
|
while (statement = statements.shift()) {
|
||||||
yield Zotero.DB.queryAsync(statement);
|
yield this.queryAsync(statement);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1259,19 +1255,19 @@ Zotero.DBConnection.prototype._getConnectionAsync = Zotero.Promise.coroutine(fun
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DB_LOCK_EXCLUSIVE) {
|
if (DB_LOCK_EXCLUSIVE) {
|
||||||
yield Zotero.DB.queryAsync("PRAGMA locking_mode=EXCLUSIVE");
|
yield this.queryAsync("PRAGMA locking_mode=EXCLUSIVE");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
yield Zotero.DB.queryAsync("PRAGMA locking_mode=NORMAL");
|
yield this.queryAsync("PRAGMA locking_mode=NORMAL");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set page cache size to 8MB
|
// Set page cache size to 8MB
|
||||||
var pageSize = yield Zotero.DB.valueQueryAsync("PRAGMA page_size");
|
var pageSize = yield this.valueQueryAsync("PRAGMA page_size");
|
||||||
var cacheSize = 8192000 / pageSize;
|
var cacheSize = 8192000 / pageSize;
|
||||||
yield Zotero.DB.queryAsync("PRAGMA cache_size=" + cacheSize);
|
yield this.queryAsync("PRAGMA cache_size=" + cacheSize);
|
||||||
|
|
||||||
// Enable foreign key checks
|
// Enable foreign key checks
|
||||||
yield Zotero.DB.queryAsync("PRAGMA foreign_keys=true");
|
yield this.queryAsync("PRAGMA foreign_keys=true");
|
||||||
|
|
||||||
// Register idle and shutdown handlers to call this.observe() for DB backup
|
// Register idle and shutdown handlers to call this.observe() for DB backup
|
||||||
var idleService = Components.classes["@mozilla.org/widget/idleservice;1"]
|
var idleService = Components.classes["@mozilla.org/widget/idleservice;1"]
|
||||||
|
|
Loading…
Reference in a new issue