Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

Wrong remote path when uploading multiple files via glob pattern (issue with path.relative) #117

Open
mankey-ru opened this issue May 31, 2018 · 2 comments

Comments

@mankey-ru
Copy link

Buggy code located in scp.js

var _upload = function(files, callback) {
    var rootdir = files[0];
    async.eachSeries(files, function(fpath, done) {
      fs.stat(fpath, function(err, stats) {
        // ...
        if (stats.isFile()) {
          var fname = path.relative(rootdir, fpath);

Problem occurs when files argument is [ 'file_A.js', 'file_B.js' ] (glob pattern 'file_' or './file_').
First file (A) transfers to remote host successfully, but second one (B) transfers to "one level up directory".
It happens because path.relative handles first argument as directory, and path.relative("file_A.js", "file_B.js") returns "..\file_B.js"

Ready code to reproduce:

var client = require('scp2');
client.scp('./file_*', {
	host: '<host>',
	username: '<username>',
	password: '<password>',
	path: '/opt/IBM/HTTPServer/htdocs/myhost/js'
}, function(err) {
	console.log(err)
})
@sla89
Copy link

sla89 commented Jun 4, 2018

Same issue here

1 similar comment
@poolye
Copy link

poolye commented Sep 11, 2021

Same issue here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants