Skip to content

Commit

Permalink
Don't calculate total file size for every uploaded attachment
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dstillman committed Jul 1, 2017
1 parent 9a3ff2d commit b72f1c2
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions chrome/content/zotero/xpcom/storage/storageEngine.js
Expand Up @@ -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));
Expand Down

0 comments on commit b72f1c2

Please sign in to comment.