Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

skipper-disk

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

skipper-disk - npm Package Compare versions

Comparing version 0.5.3 to 0.5.4

ROADMAP.md

60

index.js

@@ -25,38 +25,36 @@ /**

var adapter = {
var adapter = {};
adapter.rm = function(fd, cb) {
return fsx.unlink(fd, function(err) {
// Ignore "doesn't exist" errors
if (err && (typeof err !== 'object' || err.code !== 'ENOENT')) {
return cb(err);
} else return cb();
});
};
rm: function(fd, cb) {
return fsx.unlink(fd, function(err) {
// Ignore "doesn't exist" errors
if (err && (typeof err !== 'object' || err.code !== 'ENOENT')) {
return cb(err);
} else return cb();
});
},
adapter.ls = function(dirpath, cb) {
return fsx.readdir(dirpath, function (err, files){
if (err) return cb(err);
files = _.reduce(_.isArray(files)?files:[], function (m, filename){
var fd = path.join(dirpath,filename);
m.push(fd);
return m;
}, []);
cb(null, files);
});
};
ls: function(dirpath, cb) {
return fsx.readdir(dirpath, function (err, files){
if (err) return cb(err);
files = _.reduce(_.isArray(files)?files:[], function (m, filename){
var fd = path.join(dirpath,filename);
m.push(fd);
return m;
}, []);
cb(null, files);
});
},
read: function(fd, cb) {
if (cb) {
return fsx.readFile(fd, cb);
} else {
return fsx.createReadStream(fd);
}
},
receive: function (options){
return r_buildDiskReceiverStream(options);
adapter.read = function(fd, cb) {
if (cb) {
return fsx.readFile(fd, cb);
} else {
return fsx.createReadStream(fd);
}
};
adapter.receive = function(options) {
return r_buildDiskReceiverStream(options, adapter);
};
return adapter;

@@ -63,0 +61,0 @@ };

{
"name": "skipper-disk",
"version": "0.5.3",
"version": "0.5.4",
"description": "Receive Skipper's file uploads on your local filesystem",

@@ -36,4 +36,5 @@ "main": "index.js",

"lodash": "~2.4.1",
"node-uuid": "~1.4.1"
"node-uuid": "~1.4.1",
"debug": "^2.1.1"
}
}

@@ -9,4 +9,2 @@ # [<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

========================================
## Installation

@@ -18,7 +16,5 @@

Also make sure you have skipper [installed as your body parser](http://beta.sailsjs.org/#/documentation/concepts/Middleware?q=adding-or-overriding-http-middleware).
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.
> Skipper is installed by default in [Sails](https://github.com/balderdashy/sails) as of v0.10.
========================================

@@ -44,10 +40,11 @@ ## Usage

For more detailed usage information and a full list of available options, see the Skipper docs, especially the section on "[https://github.com/balderdashy/skipper#uploading-files-to-disk](Uploading to Local Disk)".
For more detailed usage information and a full list of available options, see the Skipper repo, especially the section on "[https://github.com/balderdashy/skipper#uploading-files-to-disk](Uploading to Local Disk)".
========================================
## Contribute
See `CONTRIBUTING.md`.
See [ROADMAP.md](https://github.com/balderdashy/skipper-s3/blob/master/ROADMAP.md).
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:

@@ -59,8 +56,7 @@

Also be sure to check out [ROADMAP.md in the Skipper repo](https://github.com/balderdashy/skipper/blob/master/ROADMAP.md).
========================================
### License
## License
**[MIT](./LICENSE)**

@@ -67,0 +63,0 @@ &copy; 2013, 2014-

@@ -10,5 +10,6 @@ /**

var r_buildProgressStream = require('./build-progress-stream');
var debug = require('debug')('skipper-disk');
var util = require('util');
/**

@@ -24,6 +25,15 @@ * A simple receiver for Skipper that writes Upstreams to

*/
module.exports = function buildDiskReceiverStream(options) {
module.exports = function buildDiskReceiverStream(options, adapter) {
options = options || {};
var log = options.log || function noOpLog(){};
// if maxBytes is configed in "MB" ended string
// convert it into bytes
if (options.maxBytes) {
var _maxBytesRegResult = (options.maxBytes + '').match(/(\d+)m/i);
if (_maxBytesRegResult != null){
options.maxBytes = _maxBytesRegResult[1] * 1024 * 1024;
}
};
_.defaults(options, {

@@ -78,5 +88,4 @@

// Determine the file descriptor-- the unique identifier.
// `__newFile.fd` is the file descriptor-- the unique identifier.
// Often represents the location where file should be written.
__newFile.fd;

@@ -99,3 +108,5 @@ // If fd DOESNT have leading slash, resolve the path

// Error reading from the file stream
debug('binding error handler for incoming file in skipper-disk');
__newFile.on('error', function(err) {
debug('Read error on file '+__newFile.filename+ '::'+ util.inspect(err&&err.stack));
log('***** READ error on file ' + __newFile.filename, '::', err);

@@ -116,3 +127,3 @@ });

var __progress__ = r_buildProgressStream(options, __newFile, receiver__, outs__);
var __progress__ = r_buildProgressStream(options, __newFile, receiver__, outs__, adapter);

@@ -119,0 +130,0 @@ // Finally pipe the progress THROUGH the progress stream

@@ -18,3 +18,3 @@ /**

*/
module.exports = function buildProgressStream (options, __newFile, receiver__, outs__) {
module.exports = function buildProgressStream (options, __newFile, receiver__, outs__, adapter) {
options = options || {};

@@ -45,3 +45,3 @@ var log = options.log || function noOpLog(){};

id: localID,
fd: __newFile._skipperFD,
fd: __newFile.fd,
name: __newFile.name,

@@ -86,3 +86,3 @@ written: writtenSoFar,

id: localID,
fd: __newFile._skipperFD,
fd: __newFile.fd,
name: __newFile.filename,

@@ -102,3 +102,3 @@ written: milestone.written,

// using the sum of all bytes written to each file in `receiver__._files`
totalBytesWritten = _.reduce(receiver__._files, function(memo, status) {
var totalBytesWritten = _.reduce(receiver__._files, function(memo, status) {
memo += status.written;

@@ -127,3 +127,5 @@ return memo;

// Unpipe the progress stream, which feeds the disk stream, so we don't keep dumping to disk
__progress__.unpipe();
process.nextTick(function() {
__progress__.unpipe();
});
// Clean up any files we've already written

@@ -133,4 +135,4 @@ (function gc(err) {

// (called when a read or write error occurs)
log('************** Garbage collecting file `' + __newFile.filename + '` located @ ' + fd + '...');
adapter.rm(fd, function(gcErr) {
log('************** Garbage collecting file `' + __newFile.filename + '` located @ ' + __newFile.fd + '...');
adapter.rm(__newFile.fd, function(gcErr) {
if (gcErr) return outs__.emit('E_EXCEEDS_UPLOAD_LIMIT',[err].concat([gcErr]));

@@ -137,0 +139,0 @@ return outs__.emit('E_EXCEEDS_UPLOAD_LIMIT',err);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc