grunt-ssh icon indicating copy to clipboard operation
grunt-ssh copied to clipboard

Cannot download all files in folder (using wildcard) on Windows due to path construction problem

Open exterrestris opened this issue 9 years ago • 0 comments

When attempting to download an entire folder using sftp (example config below), the download fails on Windows with "Warning: No such file Use --force to continue". Using --verbose shows that warning occurs immediately after "Checking existence of path C:\path\to\grunt\project/download/./files".

{
  "files": {
    "./content/files" : "content/files",
  },
  "options": {
    "createDirectories": true,
    "showProgress": true,
    "host": "example.org",
    "username": "example",
    "password": "********",
    "path": "/",
    "srcBasePath": "/httpdocs/",
    "destBasePath": "/download/",
    "mode": "download"
  }
}

Further investigation shows that the plugin is listing the contents of the directory correctly, but is then unable to download any of those files because the path that is generated uses the Windows convention of separating by \ rather than /, causing the file not to be found when requested (I assume this is due to grunt/node respecting the current platform). I have worked around this locally by adding a search-and-replace to tasks/sftp.js as follows:

...
              var downloadingRecursive = function (src, dest) {
                  src = src.replace(/\\/g, '/');
...

Whilst this quick hack works for my purposes, I suspect there is a more correct way to resolve this - unfortunately I'm afraid I don't know grunt/node well enough.

exterrestris avatar Aug 11 '15 16:08 exterrestris