open a transaction for translatorCache updates

This commit is contained in:
Simon Kornblith 2010-06-28 16:54:06 +00:00
parent b87b46aa95
commit ee8c60939a

View file

@ -49,7 +49,8 @@ Zotero.Translators = new function() {
this.init = function() {
_initialized = true;
var start = (new Date()).getTime()
var start = (new Date()).getTime();
var transactionStarted = false;
_cache = {"import":[], "export":[], "web":[], "search":[]};
_translators = {};
@ -104,6 +105,10 @@ Zotero.Translators = new function() {
if(!dbCacheEntry) {
// Add cache misses to DB
if(!transactionStarted) {
transactionStarted = true;
Zotero.DB.beginTransaction();
}
Zotero.Translators.cacheInDB(leafName, translator.metadataString, translator.cacheCode ? translator.code : null, lastModifiedTime);
delete translator.metadataString;
}
@ -120,6 +125,11 @@ Zotero.Translators = new function() {
}
}
// Close transaction
if(transactionStarted) {
Zotero.DB.commitTransaction();
}
// Sort by priority
var collation = Zotero.getLocaleCollation();
var cmp = function (a, b) {