noodny / node-ftp-client

MIT License
64 stars 32 forks source link

download crashes if destination is empty #2

Open jmzoda opened 9 years ago

jmzoda commented 9 years ago

Added list check after connect to check if list is empty : var ftpQual = new ftpClient(ftpConfig, ftpOptions); ftpQual.connect(function () { ftpQual.ftp.list('/', function (err, list) { if(err){ return callback(err); } if( list.length === 0 ) { // because ftp-clients crashes if dir is empty return callback(null, localDir); } ftpQual.download('/', localDir, { overwrite: 'all' }, function(result) { callback(null, localDir); } ); }) }); Don't hesitate...