From 4c58f248d166d37d9bf6469a20e73bcb739b7216 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 11 Dec 2012 16:46:54 -0500 Subject: [PATCH] Fix getTotalFileSize() error for file sync downloads Also fix 'undefined' in error panel for some errors --- chrome/content/zotero/xpcom/storage.js | 9 ++++++--- chrome/content/zotero/xpcom/storage/request.js | 2 +- chrome/content/zotero/xpcom/sync.js | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js index f4042aba28..5f17b817cf 100644 --- a/chrome/content/zotero/xpcom/storage.js +++ b/chrome/content/zotero/xpcom/storage.js @@ -327,7 +327,7 @@ Zotero.Sync.Storage = new function () { switch (Zotero.Sync.Storage.getSyncState(item.id)) { case this.SYNC_STATE_TO_DOWNLOAD: case this.SYNC_STATE_FORCE_DOWNLOAD: - var queue = Zotero.Sync.Storage.QueueManager.get('download', library); + var queue = 'download'; var callbacks = { onStart: function (request) { return mode.downloadFile(request); @@ -337,7 +337,7 @@ Zotero.Sync.Storage = new function () { case this.SYNC_STATE_TO_UPLOAD: case this.SYNC_STATE_FORCE_UPLOAD: - var queue = Zotero.Sync.Storage.QueueManager.get('upload', library); + var queue = 'upload'; var callbacks = { onStart: function (request) { return mode.uploadFile(request); @@ -350,10 +350,13 @@ Zotero.Sync.Storage = new function () { return; } + var queue = Zotero.Sync.Storage.QueueManager.get(queue, library); var request = new Zotero.Sync.Storage.Request( (item.libraryID ? item.libraryID : 0) + '/' + item.key, callbacks ); - request.setMaxSize(Zotero.Attachments.getTotalFileSize(item)); + if (queue == 'upload') { + request.setMaxSize(Zotero.Attachments.getTotalFileSize(item)); + } queue.addRequest(request, highPriority); }; diff --git a/chrome/content/zotero/xpcom/storage/request.js b/chrome/content/zotero/xpcom/storage/request.js index e417429cd0..961c21535b 100644 --- a/chrome/content/zotero/xpcom/storage/request.js +++ b/chrome/content/zotero/xpcom/storage/request.js @@ -31,7 +31,7 @@ * @param {Function} onStart Callback to run when request starts */ Zotero.Sync.Storage.Request = function (name, callbacks) { - //Zotero.debug("Initializing request '" + name + "'"); + Zotero.debug("Initializing request '" + name + "'"); this.callbacks = ['onStart', 'onProgress']; diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js index 863e8b383c..8cedcbf88e 100644 --- a/chrome/content/zotero/xpcom/sync.js +++ b/chrome/content/zotero/xpcom/sync.js @@ -616,6 +616,10 @@ Zotero.Sync.Runner = new function () { this.error = function (e) { + if (typeof e == 'string') { + e = new Error(e); + e.status = 'error'; + } Components.utils.reportError(e); Zotero.debug(e, 1); Zotero.Sync.Runner.setSyncIcon(e);