mscdex / node-ftp

An FTP client module for node.js
MIT License
1.13k stars 244 forks source link

rmdir (recursive) fails with unicode chacaters #276

Open rioki opened 3 years ago

rioki commented 3 years ago

I wrote a small maintenance script with the following code:

function deleteArtifact(path, cb) {
  const ftp = new FtpClient();
  ftp.on('ready', function() {
    ftp.rmdir(path, true, (err) => {
      cb(err);
      ftp.end();
    });

  });
  ftp.on('error', cb);
  ftp.connect({host: ARTIFACT_HOSTNAME, user: ARTIFACT_FTP_USER, password: ARTIFACT_FTP_PASS});
}

Now because of failures in other systems we have a test directory called "スーパーテストディレクトリ". So when trying to delete "Models\スーパーテストディレクトリ" it failes with

Error: [...]/Models/⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂: No such file or directory.
    at makeError ([...]\node_modules\ftp\lib\connection.js:1067:13)
    at Parser.<anonymous> ([...]\node_modules\ftp\lib\connection.js:113:25)
    at Parser.emit (node:events:369:20)
    at Parser._write ([...]\node_modules\ftp\lib\parser.js:59:10)
    at writeOrBuffer (node:internal/streams/writable:395:12)
    at Parser.Writable.write (node:internal/streams/writable:340:10)
    at Socket.ondata ([...]\node_modules\ftp\lib\connection.js:273:20)
    at Socket.emit (node:events:369:20)
    at addChunk (node:internal/streams/readable:313:12)
    at readableAddChunk (node:internal/streams/readable:288:9) {
  code: 550
}

Is there anyway to make node-ftp understand unicode or can this be a FTP server config issue?

4lirexa commented 1 year ago

I wrote a small maintenance script with the following code:

function deleteArtifact(path, cb) {
  const ftp = new FtpClient();
  ftp.on('ready', function() {
    ftp.rmdir(path, true, (err) => {
      cb(err);
      ftp.end();
    });

  });
  ftp.on('error', cb);
  ftp.connect({host: ARTIFACT_HOSTNAME, user: ARTIFACT_FTP_USER, password: ARTIFACT_FTP_PASS});
}

Now because of failures in other systems we have a test directory called "スーパーテストディレクトリ". So when trying to delete "Models\スーパーテストディレクトリ" it failes with

Error: [...]/Models/⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂⌂: No such file or directory.
    at makeError ([...]\node_modules\ftp\lib\connection.js:1067:13)
    at Parser.<anonymous> ([...]\node_modules\ftp\lib\connection.js:113:25)
    at Parser.emit (node:events:369:20)
    at Parser._write ([...]\node_modules\ftp\lib\parser.js:59:10)
    at writeOrBuffer (node:internal/streams/writable:395:12)
    at Parser.Writable.write (node:internal/streams/writable:340:10)
    at Socket.ondata ([...]\node_modules\ftp\lib\connection.js:273:20)
    at Socket.emit (node:events:369:20)
    at addChunk (node:internal/streams/readable:313:12)
    at readableAddChunk (node:internal/streams/readable:288:9) {
  code: 550
}

Is there anyway to make node-ftp understand unicode or can this be a FTP server config issue?

try this https://www.npmjs.com/package/@icetee/ftp