commit 3014263c89cff0e10f7cef540e5f7667144c8226
parent e17bdd85e963cd1fc9121441ebe6b34d3e902005
Author: Dan Stillman <dstillman@zotero.org>
Date: Sat, 10 Apr 2010 20:22:21 +0000
Fix a couple issues that could cause an error when emptying the trash
Diffstat:
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js
@@ -3973,7 +3973,19 @@ Zotero.Item.prototype.erase = function() {
}
Zotero.DB.query('DELETE FROM itemData WHERE itemID=?', this.id);
- Zotero.DB.query('DELETE FROM items 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();