From b72f1c2a08014b74d689a99368f900d996868ddb Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 1 Jul 2017 06:22:57 -0400 Subject: [PATCH] Don't calculate total file size for every uploaded attachment This required checking the file size of every file (including auxiliary snapshot files) in every attachment to be uploaded, and it was an estimate anyway, because snapshots are compressed, so we kept track of the compression ratio, but there was no particular reason to think later files would have the same ratio... In any case, we're not currently displaying file sync progress in 5.0 anyway, and while we should, we can probably just show a count of attachments remaining. --- .../zotero/xpcom/storage/storageEngine.js | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/chrome/content/zotero/xpcom/storage/storageEngine.js b/chrome/content/zotero/xpcom/storage/storageEngine.js index 303ecb369..51792746b 100644 --- a/chrome/content/zotero/xpcom/storage/storageEngine.js +++ b/chrome/content/zotero/xpcom/storage/storageEngine.js @@ -321,22 +321,9 @@ Zotero.Sync.Storage.Engine.prototype.queueItem = Zotero.Promise.coroutine(functi onProgress: this.onProgress }); if (type == 'upload') { - try { - request.setMaxSize(yield Zotero.Attachments.getTotalFileSize(item)); - } - // 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 (e.g., from the web). It'd be better to download files to a temp - // directory and move them into place. - if (!(yield item.getFilePathAsync())) { - Zotero.debug("File " + item.libraryKey + " not yet available to upload -- skipping"); - return; - } - - Zotero.logError(e); + if (!(yield item.fileExists())) { + Zotero.debug("File " + item.libraryKey + " not yet available to upload -- skipping"); + return; } } this.queues[type].add(request.start.bind(request));