An invalid translator file shouldn't break all translation

For now, delete it and clear it from the cache so it's updated properly going
forward, but really we want to reinstall the correct file automatically
(#903).
This commit is contained in:
Dan Stillman 2016-01-29 05:10:49 -05:00
parent 3ac4203a75
commit eb85fdc42e

View file

@ -103,8 +103,22 @@ Zotero.Translators = new function() {
} }
// Otherwise, load from file // Otherwise, load from file
else { else {
try {
var translator = yield Zotero.Translators.loadFromFile(path); var translator = yield Zotero.Translators.loadFromFile(path);
} }
catch (e) {
Zotero.logError(e);
// If translator file is invalid, delete it and clear the cache entry
// so that the translator is reinstalled the next time it's updated.
//
// TODO: Reinstall the correct translator immediately
yield OS.File.remove(path);
let sql = "DELETE FROM translatorCache WHERE fileName=?";
yield Zotero.DB.queryAsync(sql, fileName);
continue;
}
}
// When can this happen? // When can this happen?
if (!translator.translatorID) { if (!translator.translatorID) {