morris / vinyl-ftp

Blazing fast vinyl adapter for FTP
Other
388 stars 31 forks source link

How to download files from remote server? #117

Open JeffWong16 opened 6 years ago

JeffWong16 commented 6 years ago

Hi, I try to download files from remote server using below codes

conn.src('/home/jeff/test/**').pipe(gulp.dest('./test')));

But it alwalys tells me that it failed to open file. image Is my code right?

AnsonYeung commented 6 years ago

I have the same problem either. Did exactly same as yours. conn.src("/public_html/*.php").pipe(gulp.dest("./test")); and it failed to open the file.

If I use this code instead conn.src("/public_html/*.php") It only throw error in the first file, and seems no error in the subsequent ones?

AnsonYeung commented 6 years ago

After running the test script I get this:


> vinyl-ftp@0.6.1 test C:\Users\secur\Downloads\vinyl-ftp-master\vinyl-ftp-master
> set CONFIG=test/config/myserver.json&& istanbul cover node_modules/mocha/bin/_mocha test

CONN
READY
MLSD  /test
LIST  /test
MLSD  /
LIST  /
MKDIR /test
MKDIR /test/dest
PUT   /test/dest/index.html
UP    100% /test/dest/index.html
SITE  CHMOD 0777 /test/dest/index.html
DISC
  √ should set the mode (1754ms)
CONN
READY
MLSD  /test/dest
LIST  /test/dest
GET   \test\dest\index.html
  1) should download (buffered)
CONN
DISC
READY
MLSD  /test/dest
LIST  /test/dest
GET   \test\dest\index.html
  2) should download (streamed)
  clean
    √ (preparing: create files to clean up later) (47ms)
CONN
CONN
DISC
READY
MLSD  /test/clean
READY
MLSD  /test
LIST  /test/clean
LIST  /test
MLSD  /
LIST  /
MKDIR /test/clean
PUT   /test/clean/index.html
MKDIR /test/clean/cleaning
CONN
MKDIR /test/clean/js
UP    100% /test/clean/index.html
DISC
DISC
READY
MKDIR /test/clean/css
PUT   /test/clean/css/normalize.css
CONN
CONN
UP    100% /test/clean/css/normalize.css
PUT   /test/clean/cleaning/index.html
UP    100% /test/clean/cleaning/index.html
READY
PUT   /test/clean/css/style.css
READY
MLSD  /test/clean/cleaning
LIST  /test/clean/cleaning
UP    100% /test/clean/css/style.css
MKDIR /test/clean/cleaning/css
MKDIR /test/clean/cleaning/js
PUT   /test/clean/js/jquery.js
PUT   /test/clean/js/script.js
MLSD  /test/clean/js
UP    100% /test/clean/js/script.js
UP    100% /test/clean/js/jquery.js
LIST  /test/clean/js
PUT   /test/clean/cleaning/js/jquery.js
PUT   /test/clean/cleaning/js/script.js
MKDIR /test/clean/js/sub
UP    100% /test/clean/cleaning/js/jquery.js
UP    100% /test/clean/cleaning/js/script.js
MLSD  /test/clean/cleaning/js
PUT   /test/clean/cleaning/css/normalize.css
PUT   /test/clean/cleaning/css/style.css
LIST  /test/clean/cleaning/js
UP    100% /test/clean/cleaning/css/normalize.css
UP    100% /test/clean/cleaning/css/style.css
MKDIR /test/clean/cleaning/js/sub
PUT   /test/clean/js/sub/sub.js
PUT   /test/clean/cleaning/js/sub/sub.js
UP    100% /test/clean/cleaning/js/sub/sub.js
UP    100% /test/clean/js/sub/sub.js
DISC
DISC
DISC
    √ (preparing: upload all files) (2013ms)
    √ (preparing: remove files to clean)
CONN
READY
MLSD  /test/clean
LIST  /test/clean
MLSD  /test/clean/cleaning
CONN
CONN
CONN
LIST  /test/clean/cleaning
MLSD  /test/clean/cleaning/css
CONN
LIST  /test/clean/cleaning/css
READY
MLSD  /test/clean/css
READY
MLSD  /test/clean/js
READY
RMDIR /test/clean/cleaning
LIST  /test/clean/css
LIST  /test/clean/js
MLSD  /test/clean/js/sub
READY
MLSD  /test/clean/cleaning/js
LIST  /test/clean/js/sub
LIST  /test/clean/cleaning/js
MLSD  /test/clean/cleaning/js/sub
LIST  /test/clean/cleaning/js/sub
RMDIR /test/clean/cleaning/css
DEL   /test/clean/cleaning/index.html
RMDIR /test/clean/cleaning/js
DISC
DISC
DISC
DISC
DISC
    √ should clean up extra remote files (1749ms)

  dest
CONN
READY
MLSD  /test/concurrent
LIST  /test/concurrent
MLSD  /test
LIST  /test
MLSD  /
LIST  /
MKDIR /test/concurrent
MKDIR /test/concurrent/0
CONN
CONN
CONN
CONN
PUT   /test/concurrent/0/index.html
UP    100% /test/concurrent/0/index.html
READY
MKDIR /test/concurrent/1
READY
MKDIR /test/concurrent/2
READY
MKDIR /test/concurrent/4
READY
MKDIR /test/concurrent/3
PUT   /test/concurrent/1/index.html
PUT   /test/concurrent/2/index.html
PUT   /test/concurrent/4/index.html
UP    100% /test/concurrent/1/index.html
UP    100% /test/concurrent/2/index.html
UP    100% /test/concurrent/4/index.html
PUT   /test/concurrent/3/index.html
UP    100% /test/concurrent/3/index.html
DISC
DISC
DISC
DISC
DISC
    √ should not fail when called concurrently (1751ms)

  delete
CONN
CONN
READY
DEL   test/dest/index.html
READY
RMDIR test
DISC
DISC
    √ should delete (2265ms)

  dest
CONN
READY
RMDIR test
    3) "before each" hook for "should upload (streamed)"

  Of the filter methods,
CONN
DISC
READY
MLSD  /test
LIST  /test
MLSD  /
LIST  /
MKDIR /test
MKDIR /test/dest
PUT   /test/dest/index.html
UP    100% /test/dest/index.html
SITE  CHMOD 0777 /test/dest/index.html
DISC
    √ the filter method should apply a custom filter (1603ms)

  mkdirp
CONN
READY
MLSD  /test/src/foo
LIST  /test/src/foo
MLSD  /test/src
LIST  /test/src
MLSD  /test
LIST  /test
MLSD  /
LIST  /
MKDIR /test/src
MKDIR /test/src/foo
MKDIR /test/src/foo/bar
DISC
    √ should work (1612ms)

  9 passing (16s)
  3 failing

  1)  should download (buffered):
     Uncaught Error: Failed to open file.
      at makeError (node_modules\ftp\lib\connection.js:1067:13)
      at Parser.<anonymous> (node_modules\ftp\lib\connection.js:113:25)
      at Parser._write (node_modules\ftp\lib\parser.js:59:10)
      at doWrite (_stream_writable.js:397:12)
      at writeOrBuffer (_stream_writable.js:383:5)
      at Parser.Writable.write (_stream_writable.js:290:11)
      at Socket.ondata (node_modules\ftp\lib\connection.js:273:20)
      at addChunk (_stream_readable.js:263:12)
      at readableAddChunk (_stream_readable.js:250:11)
      at Socket.Readable.push (_stream_readable.js:208:10)
      at TCP.onread (net.js:597:20)

  2)  should download (streamed):
     Uncaught Error: Failed to open file.
      at makeError (node_modules\ftp\lib\connection.js:1067:13)
      at Parser.<anonymous> (node_modules\ftp\lib\connection.js:113:25)
      at Parser._write (node_modules\ftp\lib\parser.js:59:10)
      at doWrite (_stream_writable.js:397:12)
      at writeOrBuffer (_stream_writable.js:383:5)
      at Parser.Writable.write (_stream_writable.js:290:11)
      at Socket.ondata (node_modules\ftp\lib\connection.js:273:20)
      at addChunk (_stream_readable.js:263:12)
      at readableAddChunk (_stream_readable.js:250:11)
      at Socket.Readable.push (_stream_readable.js:208:10)
      at TCP.onread (net.js:597:20)

  3) dest "before each" hook for "should upload (streamed)":
     Error: Remove directory operation failed.
      at makeError (node_modules\ftp\lib\connection.js:1067:13)
      at Parser.<anonymous> (node_modules\ftp\lib\connection.js:113:25)
      at Parser._write (node_modules\ftp\lib\parser.js:59:10)
      at doWrite (_stream_writable.js:397:12)
      at writeOrBuffer (_stream_writable.js:383:5)
      at Parser.Writable.write (_stream_writable.js:290:11)
      at Socket.ondata (node_modules\ftp\lib\connection.js:273:20)
      at addChunk (_stream_readable.js:263:12)
      at readableAddChunk (_stream_readable.js:250:11)
      at Socket.Readable.push (_stream_readable.js:208:10)
      at TCP.onread (net.js:597:20)

=============================================================================
Writing coverage object [C:\Users\secur\Downloads\vinyl-ftp-master\vinyl-ftp-master\coverage\coverage.json]
Writing coverage reports at [C:\Users\secur\Downloads\vinyl-ftp-master\vinyl-ftp-master\coverage]
=============================================================================

=============================== Coverage summary ===============================
Statements   : 71.31% ( 435/610 )
Branches     : 51.36% ( 132/257 )
Functions    : 76.47% ( 91/119 )
Lines        : 76.09% ( 420/552 )
================================================================================
npm ERR! Test failed.  See above for more details.
mickenorlen commented 5 years ago

I also have a problem with downloading. In my case the upload folder from a wordpress installation:

gulp.task("importUploads", function(done) {
    var conn = ftp.create(ftpCredentials);
  conn
    .src(['/wp-content/uploads/**/*'])
    .pipe(gulp.dest(distFolder + 'wp-content/uploads/'));
  done();
});

The */ pattern doesn't match all files. I only get a 2018/06 uploads folder with less actual content than remote. So many folders and files are missing seemingly at random?

In the output it "senses" some of the folders that are skipped:

[20:06:25] MLSD  /wp-content/uploads/2018/09
[20:06:25] READY
[20:06:25] MLSD  /wp-content/uploads/2018/08

Thanks!

morris commented 5 years ago

109

dylanwe commented 4 years ago

I got the same problem