From 41449871a1ca5b1ad3f7516602aedad3cd2379ac Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 13 Apr 2013 03:41:32 -0400 Subject: [PATCH] Fix "Source item for keyed source doesn't exist" sync error This could occur in 4.0 if a standalone attachment was modified locally and remotely was changed into a child attachment. --- chrome/content/zotero/xpcom/data/item.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 208fc55d0b..796be2e6fd 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -2837,7 +2837,20 @@ Zotero.Item.prototype.getFile = function(row, skipExistsCheck) { if (self.isTopLevelItem()) { return; } - Zotero.Items.get(self.getSource()).updateBestAttachmentState(); + + try { + var parentKey = self.getSource(); + } + // This can happen during classic sync conflict resolution, if a + // standalone attachment was modified locally and remotely was changed + // into a child attachment + catch (e) { + Zotero.debug("Attachment parent doesn't exist for source key " + + "in Zotero.Item.updateAttachmentStates()", 1); + return; + } + + Zotero.Items.get(parentKey).updateBestAttachmentState(); }; // No associated files for linked URLs