Always try to commit open transactions at shutdown
This commit is contained in:
parent
0809408d4b
commit
51664bc51a
|
@ -37,6 +37,7 @@ Zotero.DB = new function(){
|
|||
this.commitTransaction = commitTransaction;
|
||||
this.rollbackTransaction = rollbackTransaction;
|
||||
this.transactionInProgress = transactionInProgress;
|
||||
this.commitAllTransactions = commitAllTransactions;
|
||||
this.tableExists = tableExists;
|
||||
this.getColumns = getColumns;
|
||||
this.getColumnHash = getColumnHash;
|
||||
|
@ -345,6 +346,24 @@ Zotero.DB = new function(){
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Safety function used on shutdown to make sure we're not stuck in the
|
||||
* middle of a transaction
|
||||
*/
|
||||
function commitAllTransactions(){
|
||||
if (transactionInProgress()){
|
||||
var level = _transactionNestingLevel;
|
||||
_transactionNestingLevel = 0;
|
||||
try {
|
||||
Zotero.DB.commitTransaction();
|
||||
}
|
||||
catch (e){}
|
||||
return level ? level : true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function tableExists(table){
|
||||
return _getDBConnection().tableExists(table);
|
||||
}
|
||||
|
|
|
@ -137,6 +137,12 @@ var Zotero = new function(){
|
|||
return false;
|
||||
}
|
||||
|
||||
var level = Zotero.DB.commitAllTransactions();
|
||||
if (level){
|
||||
level = level===true ? '0' : level;
|
||||
Zotero.debug("A transaction was still open! (level " + level + ")", 2);
|
||||
}
|
||||
|
||||
_shutdown = true;
|
||||
|
||||
Zotero.backupDatabase();
|
||||
|
|
Loading…
Reference in New Issue
Block a user