Fixes #366, Automated backup will back up a corrupted DB
We already copy to an interim temp file on shutdown--just try to open it before overwriting old backup file Still wish there was a way to detect corruption while Zotero was still open and pretending to write to the DB, but I don't know of one (other than making a copy of the DB and trying to open it, but as far as I can tell we can't release the file handle on it to then delete it or check again later)...will keep working on it.
This commit is contained in:
parent
666831748e
commit
61fab3a2dd
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user