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
This commit is contained in:
parent
46854b6b23
commit
06fb74aafd
2 changed files with 7 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue