Fix error fetching empty file via File.getContentsAsync()

This commit is contained in:
Dan Stillman 2014-09-03 19:39:32 -04:00
parent 490d24f43b
commit ff5007fdea

View file

@ -212,10 +212,20 @@ Zotero.File = new function(){
} }
try { try {
var bytesToFetch = inputStream.available();
if (maxLength && maxLength < bytesToFetch) {
bytesToFetch = maxLength;
}
if (bytesToFetch == 0) {
deferred.resolve("");
return;
}
deferred.resolve( deferred.resolve(
NetUtil.readInputStreamToString( NetUtil.readInputStreamToString(
inputStream, inputStream,
Math.min(maxLength, inputStream.available()), bytesToFetch,
options options
) )
); );