Fix a couple issues that could cause an error when emptying the trash

This commit is contained in:
Dan Stillman 2010-04-10 20:22:21 +00:00
parent e17bdd85e9
commit 3014263c89

View file

@ -3973,7 +3973,19 @@ Zotero.Item.prototype.erase = function() {
}
Zotero.DB.query('DELETE FROM itemData WHERE itemID=?', this.id);
try {
Zotero.DB.query('DELETE FROM items WHERE itemID=?', this.id);
}
catch (e) {
// If deletion fails, try to correct a few things that have come up before
Zotero.debug("Item deletion failed -- trying to fix", 2);
Zotero.DB.query('DELETE FROM fulltextItemWords WHERE itemID=?', this.id);
Zotero.DB.query('DELETE FROM itemTags WHERE itemID=?', this.id);
// And then try again
Zotero.DB.query('DELETE FROM items WHERE itemID=?', this.id);
}
try {
Zotero.DB.commitTransaction();