skipper-disk
Advanced tools
Comparing version 0.5.11 to 0.5.12
{ | ||
"name": "skipper-disk", | ||
"version": "0.5.11", | ||
"version": "0.5.12", | ||
"description": "Receive streaming file uploads on your local filesystem.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -82,13 +82,22 @@ /** | ||
// `__newFile.fd` is the file descriptor-- the unique identifier. | ||
// `skipperFd` is the file descriptor-- the unique identifier. | ||
// Often represents the location where file should be written. | ||
// | ||
// But note that we formerly used `fd`, but now Node attaches an `fd` property | ||
// to Readable streams that come from the filesystem. So this kinda messed | ||
// us up. And we had to do this instead: | ||
var skipperFd = __newFile.skipperFd || (_.isString(__newFile.fd)? __newFile.fd : undefined); | ||
if (!_.isString(skipperFd)) { | ||
return done(new Error('In skipper-disk adapter, write() method called with a stream that has an invalid `skipperFd`: '+skipperFd)); | ||
} | ||
// If fd DOESNT have leading slash, resolve the path | ||
// from process.cwd() | ||
if (!__newFile.fd.match(/^\//)) { | ||
__newFile.fd = path.resolve(process.cwd(), '.tmp/uploads', __newFile.fd); | ||
if (!skipperFd.match(/^\//)) { | ||
skipperFd = path.resolve(process.cwd(), '.tmp/uploads', skipperFd); | ||
__newFile.skipperFd = skipperFd; | ||
} | ||
// Ensure necessary parent directories exist: | ||
fsx.mkdirs(path.dirname(__newFile.fd), function(mkdirsErr) { | ||
fsx.mkdirs(path.dirname(skipperFd), function(mkdirsErr) { | ||
// If we get an error here, it's probably because the Node | ||
@@ -109,3 +118,3 @@ // user doesn't have write permissions at the designated | ||
// Create a new write stream to write to disk | ||
var outs__ = fsx.createWriteStream(__newFile.fd, encoding); | ||
var outs__ = fsx.createWriteStream(skipperFd, encoding); | ||
@@ -116,3 +125,3 @@ // When the file is done writing, call the callback | ||
// File the file entry in the receiver with the same fd as the finished stream. | ||
var file = _.find(receiver__._files, {fd: __newFile.fd}); | ||
var file = _.find(receiver__._files, {fd: skipperFd}); | ||
if (file) { | ||
@@ -148,7 +157,7 @@ // Set the byteCount of the stream to the "total" value of the file, which has | ||
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})); | ||
var newError = new Error('Error writing file `' + skipperFd + '` 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})); | ||
var newError = new Error('Error reported from the progress stream while uploading file `' + skipperFd + '` (for field `'+__newFile.field+'`): ' + util.inspect(err, {depth: 5})); | ||
receiver__.emit('error', newError); | ||
@@ -155,0 +164,0 @@ }); |
@@ -45,2 +45,3 @@ /** | ||
fd: __newFile.fd, | ||
skipperFd: (__newFile.skipperFd || (_.isString(__newFile.fd) ? __newFile.fd : undefined)), | ||
name: __newFile.name, | ||
@@ -86,2 +87,3 @@ written: writtenSoFar, | ||
fd: __newFile.fd, | ||
skipperFd: (__newFile.skipperFd || (_.isString(__newFile.fd) ? __newFile.fd : undefined)), | ||
name: __newFile.filename, | ||
@@ -132,4 +134,4 @@ written: milestone.written, | ||
// (called when a read or write error occurs) | ||
log('************** Garbage collecting file `' + __newFile.filename + '` located @ ' + __newFile.fd + '...'); | ||
adapter.rm(__newFile.fd, function(gcErr) { | ||
log('************** Garbage collecting file `' + __newFile.filename + '` located @ ' + (__newFile.skipperFd || (_.isString(__newFile.fd) ? __newFile.fd : undefined)) + '...'); | ||
adapter.rm((__newFile.skipperFd || (_.isString(__newFile.fd) ? __newFile.fd : undefined)), function(gcErr) { | ||
if (gcErr) { return outs__.emit('E_EXCEEDS_UPLOAD_LIMIT',[err].concat([gcErr])); } | ||
@@ -136,0 +138,0 @@ return outs__.emit('E_EXCEEDS_UPLOAD_LIMIT',err); |
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
29757
327