Comparing version 0.1.3 to 0.1.4
@@ -82,11 +82,35 @@ var CombinedStream = require('combined-stream'); | ||
if (value.hasOwnProperty('fd')) { | ||
fs.stat(value.path, function(err, stat) { | ||
if (err) { | ||
next(err); | ||
return; | ||
} | ||
next(null, stat.size); | ||
}); | ||
// take read range into a account | ||
// `end` = Infinity –> read file till the end | ||
// | ||
// TODO: Looks like there is bug in Node fs.createReadStream | ||
// it doesn't respect `end` options without `start` options | ||
// Fix it when node fixes it. | ||
// https://github.com/joyent/node/issues/7819 | ||
if (value.end != undefined && value.end != Infinity && value.start != undefined) { | ||
// when end specified | ||
// no need to calculate range | ||
// inclusive, starts with 0 | ||
next(null, value.end+1 - (value.start ? value.start : 0)); | ||
// not that fast snoopy | ||
} else { | ||
// still need to fetch file size from fs | ||
fs.stat(value.path, function(err, stat) { | ||
var fileSize; | ||
if (err) { | ||
next(err); | ||
return; | ||
} | ||
// update final size based on the range options | ||
fileSize = stat.size - (value.start ? value.start : 0); | ||
next(null, fileSize); | ||
}); | ||
} | ||
// or http response | ||
@@ -93,0 +117,0 @@ } else if (value.hasOwnProperty('httpVersion')) { |
@@ -5,3 +5,3 @@ { | ||
"description": "A module to create readable \"multipart/form-data\" streams. Can be used to submit forms and file uploads to other web applications.", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16376
280