Comparing version 0.0.23 to 0.0.24
@@ -8,3 +8,4 @@ /** | ||
var ftpClientsArray = []; | ||
var ftpClientsNextId = 0; | ||
var ftpClientsNextId = 1; | ||
var mime = require('mime'); | ||
@@ -46,3 +47,6 @@ /** | ||
user: request.param('username'), | ||
password: request.param('password') | ||
password: request.param('password'), | ||
connTimeout: 90000, | ||
pasvTimeout: 90000, | ||
keepalive: 10 | ||
}); | ||
@@ -68,4 +72,4 @@ ftpClientsArray[request.session.ftpClientId].on('ready', function (){ | ||
request.session.ftp_user = undefined; | ||
if (request.session.ftpClientsArray[request.session.ftpClientId]) { | ||
request.session.ftpClientsArray[request.session.ftpClientId] = undefined; | ||
if (ftpClientsArray[request.session.ftpClientId]) { | ||
ftpClientsArray[request.session.ftpClientId] = undefined; | ||
request.session.ftpClientId = -1; | ||
@@ -92,4 +96,4 @@ } | ||
request.session.ftp_user = undefined; | ||
if (request.session.ftpClientsArray[request.session.ftpClientId]) { | ||
request.session.ftpClientsArray[request.session.ftpClientId] = undefined; | ||
if (ftpClientsArray[request.session.ftpClientId]) { | ||
ftpClientsArray[request.session.ftpClientId] = undefined; | ||
request.session.ftpClientId = -1; | ||
@@ -104,16 +108,20 @@ } | ||
console.error('FTP end', request.param('username')); | ||
// stop listening | ||
ftpClientsArray[request.session.ftpClientId].removeAllListeners(); | ||
// logged out | ||
if (request.session.ftp_user){ | ||
request.session.ftp_user = undefined; | ||
if (request.session.ftpClientsArray[request.session.ftpClientId]) { | ||
request.session.ftpClientsArray[request.session.ftpClientId] = undefined; | ||
request.session.ftpClientId = -1; | ||
} | ||
if (request.session.ftpClientId > 0){ | ||
// stop listening | ||
ftpClientsArray[request.session.ftpClientId].removeAllListeners(); | ||
// logged out | ||
if (request.session.ftp_user){ | ||
request.session.ftp_user = undefined; | ||
if (ftpClientsArray[request.session.ftpClientId]) { | ||
ftpClientsArray[request.session.ftpClientId] = undefined; | ||
request.session.ftpClientId = -1; | ||
} | ||
} | ||
//ftpClientsArray[request.session.ftpClientId].end(); | ||
ftpClientsArray[request.session.ftpClientId] = null; | ||
request.session.ftpClientId = -1; | ||
} | ||
ftpClientsArray[request.session.ftpClientId].end(); | ||
}; | ||
//ftpClientsArray[request.session.ftpClientId].on('end', onEnd); | ||
//ftpClientsArray[request.session.ftpClientId].on('close', onEnd); | ||
ftpClientsArray[request.session.ftpClientId].on('end', onEnd); | ||
ftpClientsArray[request.session.ftpClientId].on('close', onEnd); | ||
} | ||
@@ -184,9 +192,7 @@ /** | ||
exports.logout = function (request, response, next, cbk) { | ||
if (request.session.ftp_user){ | ||
if (request.session.ftp_user && request.session.ftpClientId > 0 && ftpClientsArray){ | ||
request.session.ftp_user = undefined; | ||
if (request.session.ftpClientsArray[request.session.ftpClientId]) { | ||
request.session.ftpClientsArray[request.session.ftpClientId] = undefined; | ||
request.session.ftpClientId = -1; | ||
if (ftpClientsArray[request.session.ftpClientId]) { | ||
ftpClientsArray[request.session.ftpClientId].end(); | ||
} | ||
ftpClientsArray[request.session.ftpClientId].end(); | ||
cbk({success:true, message:"Now logged out."}); | ||
@@ -261,3 +267,2 @@ } | ||
if (file.name && file.name != ''){ | ||
//console.dir(file); | ||
filesData.push({ | ||
@@ -424,2 +429,3 @@ bytes: file.size, | ||
if (!err) { | ||
/* | ||
var data = ''; | ||
@@ -433,6 +439,17 @@ stream.on('data', function (chunk) { | ||
stream.once('close', function () { | ||
cbk({success:true}, data); | ||
console.log('mime', path, mime.lookup(path), typeof data); | ||
console.log('mime', data.length); | ||
}); | ||
*/ | ||
var resolvedPath = pathModule.resolve(__dirname, '../../download.' + Math.round(Math.random()*99999) + '.' + (new Date()).getTime() + '.tmp'); | ||
stream.once('close', function() { | ||
cbk(undefined, undefined, mime.lookup(path), resolvedPath); | ||
setTimeout(function(){ | ||
fs.unlink(resolvedPath); | ||
}, 10000); | ||
}); | ||
stream.pipe(fs.createWriteStream(resolvedPath)); | ||
} | ||
else{ | ||
fs.unlink(resolvedPath); | ||
cbk({success:false, message: err.message, code: err.code}); | ||
@@ -439,0 +456,0 @@ } |
{ | ||
"name": "unifile", | ||
"description": "Express middleware to provide a common API for cloud storage services. ", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"author": { | ||
@@ -24,3 +24,4 @@ "name": "Alex Hoyau aka lexoyo" | ||
"oauth": "", | ||
"path": "" | ||
"path": "", | ||
"mime": "" | ||
}, | ||
@@ -27,0 +28,0 @@ "devDependencies": { |
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
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
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
2430
101558
12
28
4
+ Addedmime@
+ Addedmime@4.0.4(transitive)