skipper-disk
Advanced tools
Comparing version 0.5.9 to 0.5.10
22
index.js
@@ -6,5 +6,5 @@ /** | ||
var path = require('path'); | ||
var _ = require('lodash'); | ||
var _ = require('@sailshq/lodash'); | ||
var fsx = require('fs-extra'); | ||
var r_buildDiskReceiverStream = require('./standalone/build-disk-receiver-stream'); | ||
var buildDiskReceiverStream = require('./standalone/build-disk-receiver-stream'); | ||
@@ -21,7 +21,5 @@ | ||
module.exports = function DiskStore(options) { | ||
module.exports = function SkipperDisk(options) { | ||
options = options || {}; | ||
var log = options.log || function _noOpLog() {}; | ||
var adapter = {}; | ||
@@ -33,3 +31,6 @@ adapter.rm = function(fd, cb) { | ||
return cb(err); | ||
} else return cb(); | ||
} | ||
else { | ||
return cb(); | ||
} | ||
}); | ||
@@ -40,3 +41,4 @@ }; | ||
return fsx.readdir(dirpath, function (err, files){ | ||
if (err) return cb(err); | ||
if (err) { return cb(err); } | ||
files = _.reduce(_.isArray(files)?files:[], function (m, filename){ | ||
@@ -47,3 +49,5 @@ var fd = path.join(dirpath,filename); | ||
}, []); | ||
cb(null, files); | ||
cb(undefined, files); | ||
}); | ||
@@ -61,3 +65,3 @@ }; | ||
adapter.receive = function(opts) { | ||
return r_buildDiskReceiverStream(_.defaults(opts, options), adapter); | ||
return buildDiskReceiverStream(_.defaults(opts, options), adapter); | ||
}; | ||
@@ -64,0 +68,0 @@ |
{ | ||
"name": "skipper-disk", | ||
"version": "0.5.9", | ||
"description": "Receive Skipper's file uploads on your local filesystem", | ||
"version": "0.5.10", | ||
"description": "Receive streaming file uploads on your local filesystem.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node -e \"require('skipper-adapter-tests')({module: require('./')});\"" | ||
"lint": "node ./node_modules/eslint/bin/eslint ./ --max-warnings=0", | ||
"custom-tests": "node -e \"require('skipper-adapter-tests')({module: require('./')});\"", | ||
"test": "npm run lint && npm run custom-tests" | ||
}, | ||
@@ -29,11 +31,12 @@ "repository": { | ||
}, | ||
"homepage": "https://github.com/balderdashy/skipper-disk", | ||
"homepage": "https://sailsjs.com/support", | ||
"dependencies": { | ||
"@sailshq/lodash": "^3.10.2", | ||
"debug": "3.1.0", | ||
"fs-extra": "0.30.0" | ||
}, | ||
"devDependencies": { | ||
"skipper-adapter-tests": "~1.5.8" | ||
}, | ||
"dependencies": { | ||
"debug": "2.2.0", | ||
"fs-extra": "0.30.0", | ||
"lodash": "3.10.1" | ||
"eslint": "3.19.0", | ||
"skipper-adapter-tests": "^1.5.8" | ||
} | ||
} |
@@ -15,6 +15,8 @@ # [<img title="skipper-disk - Local disk adapter for Skipper" src="http://i.imgur.com/P6gptnI.png" width="200px" alt="skipper emblem - face of a ship's captain"/>](https://github.com/balderdashy/skipper-disk) Disk Blob Adapter | ||
If you're using this module with Express, Connect, Kraken, or a vanilla Node.js server, make sure you have skipper itself [installed as your body parser](http://beta.sailsjs.org/#/documentation/concepts/Middleware?q=adding-or-overriding-http-middleware). This is the default configuration in [Sails](https://github.com/balderdashy/sails) as of v0.10. | ||
This module is part of the default configuration in [Sails](https://sailsjs.com). | ||
> If you're using this module outside of Sails (e.g. Express or a vanilla Node.js server), make sure you have skipper itself [installed as your body parser](https://sailsjs.com/documentation/concepts/middleware?q=adding-or-overriding-http-middleware). | ||
## Usage | ||
@@ -44,6 +46,4 @@ | ||
See [ROADMAP.md](https://github.com/balderdashy/skipper-s3/blob/master/ROADMAP.md). | ||
Check out the [contribution guide](https://sailsjs.com/contributing) and [roadmap](https://trello.com/b/s9zEnyG7). | ||
Also be sure to check out [ROADMAP.md in the Skipper repo](https://github.com/balderdashy/skipper/blob/master/ROADMAP.md). | ||
To run the tests: | ||
@@ -61,9 +61,8 @@ | ||
**[MIT](./LICENSE)** | ||
© 2013, 2014- | ||
[Mike McNeil](http://michaelmcneil.com), [Balderdash](http://balderdash.co) & contributors | ||
[Mike McNeil](https://sailsjs.com/studio), [Balderdash Design Co.](http://balderdash.co), [Sails Co.](https://sailsjs.com/about) | ||
See `LICENSE.md`. | ||
This module is part of the [Sails framework](http://sailsjs.org), and is free and open-source under the [MIT License](http://sails.mit-license.org/). | ||
This module is part of the [Sails framework](https://sailsjs.com), and is free and open-source under the [MIT License](https://sailsjs.com/license). | ||
@@ -73,3 +72,1 @@ | ||
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/a22d3919de208c90c898986619efaa85 "githalytics.com")](http://githalytics.com/balderdashy/sails.io.js) |
@@ -7,5 +7,5 @@ /** | ||
var path = require('path'); | ||
var _ = require('lodash'); | ||
var _ = require('@sailshq/lodash'); | ||
var fsx = require('fs-extra'); | ||
var r_buildProgressStream = require('./build-progress-stream'); | ||
var buildProgressStream = require('./build-progress-stream'); | ||
var debug = require('debug')('skipper-disk'); | ||
@@ -33,3 +33,3 @@ var util = require('util'); | ||
var _maxBytesRegResult = (options.maxBytes + '').match(/(\d+)m/i); | ||
if (_maxBytesRegResult != null){ | ||
if (!_.isNull(_maxBytesRegResult)){ | ||
options.maxBytes = _maxBytesRegResult[1] * 1024 * 1024; | ||
@@ -78,7 +78,3 @@ } | ||
// Keep track of the number total bytes written so that maxBytes can | ||
// be enforced. | ||
var totalBytesWritten = 0; | ||
// This `_write` method is invoked each time a new file is received | ||
@@ -142,4 +138,20 @@ // from the Readable stream (Upstream) which is pumping filestreams | ||
var __progress__ = r_buildProgressStream(options, __newFile, receiver__, outs__, adapter); | ||
// Create another stream that simply keeps track of the progress of the file stream and emits `progress` events | ||
// on the receiver. | ||
var __progress__ = buildProgressStream(options, __newFile, receiver__, outs__, adapter); | ||
// Forward any uncaught errors to the receiver. | ||
// | ||
// Note -- it's important to forward using `.emit` rather than calling `done()`, because if for some reason an error occurs | ||
// _after_ the receiver stream closes, calling the `done()` method will throw another error. | ||
// Skipper core handles errors on the receiver and can deal with those errors even after the receiver stream has closed. | ||
outs__.on('error', function(err) { | ||
var newError = new Error('Error writing file `' + __newFile.fd + '` to disk (for field `'+__newFile.field+'`): ' + util.inspect(err, {depth: 5})); | ||
receiver__.emit('error', newError); | ||
}); | ||
__progress__.on('error', function(err) { | ||
var newError = new Error('Error reported from the progress stream while uploading file `' + __newFile.fd + '` (for field `'+__newFile.field+'`): ' + util.inspect(err, {depth: 5})); | ||
receiver__.emit('error', newError); | ||
}); | ||
// Finally pipe the progress THROUGH the progress stream | ||
@@ -146,0 +158,0 @@ // and out to disk. |
@@ -5,3 +5,3 @@ /** | ||
var _ = require('lodash'); | ||
var _ = require('@sailshq/lodash'); | ||
var TransformStream = require('stream').Transform; | ||
@@ -133,3 +133,3 @@ | ||
adapter.rm(__newFile.fd, function(gcErr) { | ||
if (gcErr) return outs__.emit('E_EXCEEDS_UPLOAD_LIMIT',[err].concat([gcErr])); | ||
if (gcErr) { return outs__.emit('E_EXCEEDS_UPLOAD_LIMIT',[err].concat([gcErr])); } | ||
return outs__.emit('E_EXCEEDS_UPLOAD_LIMIT',err); | ||
@@ -136,0 +136,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
29211
13
316
2
69
+ Added@sailshq/lodash@^3.10.2
+ Added@sailshq/lodash@3.10.6(transitive)
+ Addeddebug@3.1.0(transitive)
+ Addedms@2.0.0(transitive)
- Removedlodash@3.10.1
- Removeddebug@2.2.0(transitive)
- Removedlodash@3.10.1(transitive)
- Removedms@0.7.1(transitive)
Updateddebug@3.1.0