From df9439f9a2d3a913a67ec7016d12e4fbc8db4aae Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 6 Oct 2013 23:48:49 -0400 Subject: [PATCH] Don't fail during file upload if file doesn't yet exist --- chrome/content/zotero/xpcom/storage.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js index c49ef8bfb..01ee860c9 100644 --- a/chrome/content/zotero/xpcom/storage.js +++ b/chrome/content/zotero/xpcom/storage.js @@ -461,8 +461,18 @@ Zotero.Sync.Storage = new function () { try { request.setMaxSize(Zotero.Attachments.getTotalFileSize(item)); } - // If this fails, it's no big deal, though we might fail later + // If this fails, ignore it, though we might fail later catch (e) { + // But if the file doesn't exist yet, don't try to upload it + // + // This isn't a perfect test, because the file could still be + // in the process of being downloaded. It'd be better to + // download files to a temp directory and move them into place. + if (!item.getFile()) { + Zotero.debug("File " + item.libraryKey + " not yet available to upload -- skipping"); + return; + } + Components.utils.reportError(e); Zotero.debug(e, 1); }