From eb85fdc42e39e9c844169bc947f4e5487252f72a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 29 Jan 2016 05:10:49 -0500 Subject: [PATCH] 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). --- .../zotero/xpcom/translation/translators.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/translation/translators.js b/chrome/content/zotero/xpcom/translation/translators.js index 70bb548119..b7e053813b 100644 --- a/chrome/content/zotero/xpcom/translation/translators.js +++ b/chrome/content/zotero/xpcom/translation/translators.js @@ -103,7 +103,21 @@ Zotero.Translators = new function() { } // Otherwise, load from file else { - var translator = yield Zotero.Translators.loadFromFile(path); + try { + 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?