commit 4c58f248d166d37d9bf6469a20e73bcb739b7216
parent bb93f019dcde62568c846aec25934379801f48ed
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 11 Dec 2012 16:46:54 -0500
Fix getTotalFileSize() error for file sync downloads
Also fix 'undefined' in error panel for some errors
Diffstat:
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git 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
@@ -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
@@ -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);