realtymaps / promise-sftp

a promise-based sftp client for node.js
MIT License
16 stars 11 forks source link

Recursive mkdir just makes the same directory repeatedly #4

Closed thebwt closed 8 years ago

thebwt commented 8 years ago

I'm very new to all of this, but we need to get a copy of currPath at .then()'s first call time. Not currPath when everything is ready to be run.

thebwt commented 8 years ago

I was able to make some progress on this in the raw rendered javascript. (this is around line 414 in my promseSftp.js file)

        var addMkdirJob = function (newPath) {
          return _this.mkdir(newPath, false, attributes)
        }
        result = result.then(addMkdirJob(currPath))["catch"](function(err) {
          if (err.code !== ERROR_CODES.FAILURE && err.code !== ERROR_CODES.FILE_ALREADY_EXISTS) {
            throw err;
          }
        });

That allows the path to get set in the correct scope. Now I'll start looking at a way to get it working with coffeescript

thebwt commented 8 years ago

With that, the fix should be implemented.

zacronos commented 8 years ago

Thanks for the contribution!

thebwt commented 8 years ago

No problemo, was a good intro to javascript/coffee script