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

using scp2 in node-webkit #8

Open
JackieLin opened this issue Apr 11, 2014 · 2 comments
Open

using scp2 in node-webkit #8

JackieLin opened this issue Apr 11, 2014 · 2 comments

Comments

@JackieLin
Copy link

Hello:
node-scp2 is a good tool to upload or download file from remote. When I use client.scp method in node-webkit, I meet a problem: first time the code run perfectly, but when I click the upload button to run this code again, it throw an exception. It refuse me. After I look over the scp2 source code, I found this in scp.jsfile:

async.eachSeries(files, function(fpath, done) {
  fs.stat(fpath, function(err, stats) {
    if (err) {
      done(err);
      return;
    }
    if (stats.isFile()) {
      var fname = path.relative(rootdir, fpath);
      client.upload(
        fpath, path.join(client.remote.path, fname), done
      );
    } else {
      done();
    }
  });
}, function(err) {
  // never forget to close the session close by myself
  client.on('close', function() {
    callback(err);
  });
  client.close();
});

This problem is because that after client.scp method, it close the connection automatically, so next time when I run this method, the code throw an error!

I suggest that whether client.scp method can add a parameter like autoclose: false?? so user can choose whether the connection should be closed or not.

Thanks!!

@kjerniga
Copy link

I'm facing the same issue. Retries work if I comment out the client.close(), but I think the connection over time will eventually drop. If I let it close completely, and retry I get:

path.js:299
return splitPathRe.exec(filename).slice(1);
^
RangeError: Maximum call stack size exceeded

Anyone figured out how to do a retry successfully?

@kjerniga
Copy link

I just created a new instance of the client for the retry and it works.

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

2 participants