From 147cd45f0798b8de80dc205a5bc838b078b5d901 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 26 Jul 2009 09:23:59 +0000 Subject: [PATCH] Display more helpful message on upgrade errors due to open files --- chrome/content/zotero/xpcom/schema.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index 87855e29ee..02382527c7 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -57,6 +57,11 @@ Zotero.Schema = new function(){ "zotero-schema-upgrade", "chrome,centerscreen,modal", io); if (obj.data.e) { + if (obj.data.e.name && obj.data.e.name == "NS_ERROR_FAILURE" && obj.data.e.message.match(/nsIFile\.moveTo/)) { + Components.utils.reportError(obj.data.e); + return false; + } + var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] .getService(Components.interfaces.nsIWindowWatcher); var data = { @@ -2396,6 +2401,21 @@ Zotero.Schema = new function(){ } } Zotero.DB.rollbackTransaction(); + + // Display more helpful message on errors due to open files + // + // Conditional should be same as in showUpgradeWizard() + if (e.name && e.name == "NS_ERROR_FAILURE" && e.message.match(/nsIFile\.moveTo/)) { + // TODO: localize + var pr = Components.classes["@mozilla.org/network/default-prompt;1"] + .getService(Components.interfaces.nsIPrompt); + var title = "Upgrade Failed"; + var couldNotMigrate = "Zotero could not migrate all necessary files."; + var closeAttachmentFiles = "Please close any open attachment files and restart Firefox to try the upgrade again."; + var restartYourComputer = "If you continue to receive this message, restart your computer."; + pr.alert(title, Zotero.localeJoin([couldNotMigrate, closeAttachmentFiles]) + "\n\n" + restartYourComputer); + } + throw(e); }