pixl-server-storage 3.0.12 → 3.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -256,7 +256,7 @@ module.exports = Class.create({
256
256
  else if (!isNaN(start) && isNaN(end)) {
257
257
  end = buf.length ? buf.length - 1 : 0;
258
258
  }
259
- if ((start < 0) || (start >= buf.length) || (end < start) || (end >= buf.length)) {
259
+ if (isNaN(start) || isNaN(end) || (start < 0) || (start >= buf.length) || (end < start) || (end >= buf.length)) {
260
260
  download.destroy();
261
261
  callback( new Error("Invalid byte range (" + start + '-' + end + ") for key: " + key + " (len: " + buf.length + ")"), null );
262
262
  return;
@@ -488,7 +488,7 @@ module.exports = Class.create({
488
488
  else if (!isNaN(start) && isNaN(end)) {
489
489
  end = stats.size ? stats.size - 1 : 0;
490
490
  }
491
- if ((start < 0) || (start >= stats.size) || (end < start) || (end >= stats.size)) {
491
+ if (isNaN(start) || isNaN(end) || (start < 0) || (start >= stats.size) || (end < start) || (end >= stats.size)) {
492
492
  download.destroy();
493
493
  callback( new Error("Invalid byte range (" + start + '-' + end + ") for key: " + key + " (len: " + stats.size + ")"), null );
494
494
  return;
package/engines/Redis.js CHANGED
@@ -260,7 +260,7 @@ module.exports = Class.create({
260
260
  else if (!isNaN(start) && isNaN(end)) {
261
261
  end = buf.length ? buf.length - 1 : 0;
262
262
  }
263
- if ((start < 0) || (start >= buf.length) || (end < start) || (end >= buf.length)) {
263
+ if (isNaN(start) || isNaN(end) || (start < 0) || (start >= buf.length) || (end < start) || (end >= buf.length)) {
264
264
  download.destroy();
265
265
  callback( new Error("Invalid byte range (" + start + '-' + end + ") for key: " + key + " (len: " + buf.length + ")"), null );
266
266
  return;
@@ -277,7 +277,7 @@ module.exports = Class.create({
277
277
  else if (!isNaN(start) && isNaN(end)) {
278
278
  end = buf.length ? buf.length - 1 : 0;
279
279
  }
280
- if ((start < 0) || (start >= buf.length) || (end < start) || (end >= buf.length)) {
280
+ if (isNaN(start) || isNaN(end) || (start < 0) || (start >= buf.length) || (end < start) || (end >= buf.length)) {
281
281
  download.destroy();
282
282
  callback( new Error("Invalid byte range (" + start + '-' + end + ") for key: " + key + " (len: " + buf.length + ")"), null );
283
283
  return;
package/engines/S3.js CHANGED
@@ -338,7 +338,14 @@ module.exports = Class.create({
338
338
  this.logDebug(9, "Fetching ranged S3 stream: " + key, { start, end });
339
339
 
340
340
  var params = { Key: this.extKey(key, orig_key) };
341
- var download = self.s3.getObject( Tools.mergeHashes(params, { Range: "bytes=" + start + "-" + end }) ).createReadStream();
341
+
342
+ // convert start/end to HTTP range header string
343
+ var range = "bytes=";
344
+ if (!isNaN(start)) range += start;
345
+ range += '-';
346
+ if (!isNaN(end)) range += end;
347
+
348
+ var download = self.s3.getObject( Tools.mergeHashes(params, { Range: range }) ).createReadStream();
342
349
  var proceed = false;
343
350
 
344
351
  download.on('error', function(err) {
@@ -373,7 +380,7 @@ module.exports = Class.create({
373
380
  else if (!isNaN(start) && isNaN(end)) {
374
381
  end = data.ContentLength ? data.ContentLength - 1 : 0;
375
382
  }
376
- if ((start < 0) || (start >= data.ContentLength) || (end < start) || (end >= data.ContentLength)) {
383
+ if (isNaN(start) || isNaN(end) || (start < 0) || (start >= data.ContentLength) || (end < start) || (end >= data.ContentLength)) {
377
384
  download.destroy();
378
385
  callback( new Error("Invalid byte range (" + start + '-' + end + ") for key: " + key + " (len: " + data.ContentLength + ")"), null );
379
386
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixl-server-storage",
3
- "version": "3.0.12",
3
+ "version": "3.0.13",
4
4
  "description": "A key/value/list storage component for the pixl-server framework.",
5
5
  "author": "Joseph Huckaby <jhuckaby@gmail.com>",
6
6
  "homepage": "https://github.com/jhuckaby/pixl-server-storage",