From 5f0aa6aa9fd12224d8fc25102c9776cc1c4bf38b Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 8 Oct 2008 18:49:48 +0000 Subject: [PATCH] Better handling of missing attachments and empty attachment paths --- chrome/content/zotero/xpcom/data/item.js | 13 +++++++++++-- chrome/content/zotero/xpcom/storage.js | 5 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 50a8ba811..5556dede6 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -1936,8 +1936,12 @@ Zotero.Item.prototype.numNotes = function() { /** -* Get the first line of the note for display in the items list -**/ + * Get the first line of the note for display in the items list + * + * Note: Note titles can also come from Zotero.Items.cacheFields()! + * + * @return {String} + */ Zotero.Item.prototype.getNoteTitle = function() { if (!this.isNote() && !this.isAttachment()) { throw ("getNoteTitle() can only be called on notes and attachments"); @@ -2127,6 +2131,11 @@ Zotero.Item.prototype.getFile = function(row, skipExistsCheck) { return false; } + if (!row.path) { + Zotero.debug("Attachment path is empty", 2); + return false; + } + if (row.linkMode == Zotero.Attachments.LINK_MODE_IMPORTED_URL || row.linkMode == Zotero.Attachments.LINK_MODE_IMPORTED_FILE) { try { diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js index 74e7fbd80..aaad03647 100644 --- a/chrome/content/zotero/xpcom/storage.js +++ b/chrome/content/zotero/xpcom/storage.js @@ -1083,8 +1083,9 @@ Zotero.Sync.Storage = new function () { var file = item.getFile(); if (!file) { - _error("File " + file.leafName + " not found for item " - + itemID + " after extracting ZIP"); + _removeRequest(request); + _queueAdvance('download', Zotero.Sync.Storage.downloadFile, true); + _error("File not found for item " + item.id + " after extracting ZIP"); } file.lastModifiedTime = syncModTime * 1000;