commit 06fb74aafda57971f2c36a96c5553cf814bd9da9
parent 46854b6b238d0e9d3df28e188c40aa9928abc0db
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 6 Feb 2018 23:45:13 -0500
Use rowid to clean invalid entries from translatorCache
Since in truly weird cases [1] fileName might not exist
https://forums.zotero.org/discussion/comment/300558/#Comment_300558
Diffstat:
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js
@@ -744,7 +744,7 @@ Zotero.Schema = new function(){
index[id].extract = true;
}
- let sql = "SELECT fileName, metadataJSON FROM translatorCache";
+ let sql = "SELECT rowid, fileName, metadataJSON FROM translatorCache";
let rows = yield Zotero.DB.queryAsync(sql);
// If there's anything in the cache, see what we actually need to extract
for (let i = 0; i < rows.length; i++) {
@@ -757,10 +757,10 @@ Zotero.Schema = new function(){
Zotero.logError(e);
Zotero.debug(json, 1);
- // // If JSON is invalid, clear from cache
+ // If JSON is invalid, clear from cache
yield Zotero.DB.queryAsync(
- "DELETE FROM translatorCache WHERE fileName=?",
- rows[i].fileName
+ "DELETE FROM translatorCache WHERE rowid=?",
+ rows[i].rowid
);
continue;
}
diff --git a/chrome/content/zotero/xpcom/translation/translators.js b/chrome/content/zotero/xpcom/translation/translators.js
@@ -68,7 +68,7 @@ Zotero.Translators = new function() {
_cache = {"import":[], "export":[], "web":[], "webWithTargetAll":[], "search":[]};
_translators = {};
- var sql = "SELECT fileName, metadataJSON, lastModifiedTime FROM translatorCache";
+ var sql = "SELECT rowid, fileName, metadataJSON, lastModifiedTime FROM translatorCache";
var dbCacheResults = yield Zotero.DB.queryAsync(sql);
var dbCache = {};
for (let i = 0; i < dbCacheResults.length; i++) {
@@ -211,7 +211,8 @@ Zotero.Translators = new function() {
for (let fileName in dbCache) {
if (!filesInCache[fileName]) {
yield Zotero.DB.queryAsync(
- "DELETE FROM translatorCache WHERE fileName = ?", fileName
+ "DELETE FROM translatorCache WHERE rowid=?",
+ dbCache[fileName].rowid
);
}
}