diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index e4d9cc27b..0830f0d8a 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -186,9 +186,6 @@ var Zotero = new function(){ /* * Back up the main database file - * - * This could probably create a corrupt file fairly easily if all changes - * haven't been flushed to disk -- proceed with caution */ function backupDatabase(){ if (Zotero.DB.transactionInProgress()){ @@ -216,6 +213,17 @@ var Zotero = new function(){ throw (e); } + try { + var store = Components.classes["@mozilla.org/storage/service;1"]. + getService(Components.interfaces.mozIStorageService); + + var connection = store.openDatabase(tmpFile); + } + catch (e){ + Zotero.debug("Database file is corrupt--skipping backup"); + return false; + } + // Remove old backup file if (backupFile.exists()){ backupFile.remove(null); diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index 40859ccd4..a8daf6942 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -178,7 +178,7 @@ ingester.scrapeError = Could Not Save Item. ingester.scrapeErrorDescription = An error occurred while saving this item. Please try again. If this error persists, contact the translator author. db.dbCorruptedNoBackup = The Zotero database appears to have become corrupted, and no automatic backup is available.\n\nA new database file has been created. The damaged file was saved in your Zotero directory. -db.dbRestored = The Zotero database appears to have become corrupted.\n\nYour data was restored from the last automatic backup made on %1$s at %2$s. The damaged file was saved in your Zotero directory. +db.dbRestored = The Zotero database appears to have become corrupted.\n\nYour data was restored from the last automatic backup made on %1$S at %2$S. The damaged file was saved in your Zotero directory. db.dbRestoreFailed = The Zotero database appears to have become corrupted, and an attempt to restore from the last automatic backup failed.\n\nA new database file has been created. The damaged file was saved in your Zotero directory. zotero.preferences.status.positionChange = Position change will take effect in new windows only