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

unifile

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unifile - npm Package Compare versions

Comparing version 0.0.23 to 0.0.24

67

lib/services/ftp.js

@@ -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": {

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