mscdex / node-ftp

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

Directory not empty when calling rmdir recursively #159

Open mrmnmly opened 8 years ago

mrmnmly commented 8 years ago

I'm trying to remove folder with its contents using rmdir method with recursive parameter that is set to true.

Documentation says:

If recursive, this call will delete the contents of the directory if it is not empty.

But I'm getting an error:

throw new Error(err)
             ^
Error: Error: /path_on_ftp: Directory not empty

Anyone tried similar operation? Please help.

Eschon commented 7 years ago

I also have this problem.

In my case it works on directories that only contain files, but on directories that contain other directories it fails.

Here's the error that I get, I'm not sure how usefull it is since I use your library through promise-ftp. I'll try to reproduce it with your library alone on monday.

{ Error: /htdocs/images/icons: Das Verzeichnis ist nicht leer
    at makeError (/Users/egon/src/iski.world/node_modules/ftp/lib/connection.js:1067:13)
    at Parser.<anonymous> (/Users/egon/src/iski.world/node_modules/ftp/lib/connection.js:113:25)
    at emitTwo (events.js:106:13)
    at Parser.emit (events.js:191:7)
    at Parser._write (/Users/egon/src/iski.world/node_modules/ftp/lib/parser.js:59:10)
    at doWrite (_stream_writable.js:307:12)
    at writeOrBuffer (_stream_writable.js:293:5)
    at Parser.Writable.write (_stream_writable.js:220:11)
    at Socket.ondata (/Users/egon/src/iski.world/node_modules/ftp/lib/connection.js:273:20)
    at emitOne (events.js:96:13) code: 550 }
Eschon commented 7 years ago

Ok I just tested it with this library and it seems to work now. So in my case the issue is probably with promise-ftp

lfcgomes commented 7 years ago

I cannot delete a folder that is not empty :(

this is my code :

c.on('ready', function() {
switch(itemType){
    case 'file':
        c.delete(itemID, function(err) {
            c.end();
            callback(err);
         });
         break;
    case 'folder':
        c.rmdir(itemID, true, function(err) {
            c.end();
            callback(err);
        });
        break;
    default:
        callback(true);
        }
    });

And I'm always getting the same error:

error:  { [Error: Can't remove directory: Directory not empty]
  cause: { [Error: Can't remove directory: Directory not empty] code: 550 },
  isOperational: true,
   code: 550 }

Any idea?