www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 1179d4c142054cf3119b76efa969c0bb5b1a5190
parent 311ed7a71db4baa3be462f8ea772e37419513f97
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sun, 26 Apr 2015 16:53:00 -0400

Fix Zotero.File.getBinaryContentsAsync() with no maxLength

And properly reject promise on failure

Diffstat:
Mchrome/content/zotero/xpcom/file.js | 18++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js @@ -261,12 +261,18 @@ Zotero.File = new function(){ deferred.reject(new Components.Exception("Source read operation failed", status)); return; } - deferred.resolve( - NetUtil.readInputStreamToString( - inputStream, - Math.min(maxLength, inputStream.available()) - ) - ); + try { + var availableBytes = inputStream.available(); + deferred.resolve( + NetUtil.readInputStreamToString( + inputStream, + maxLength ? Math.min(maxLength, availableBytes) : availableBytes + ) + ); + } + catch (e) { + deferred.reject(e); + } }); return deferred.promise; }