ryanmcgrath / wrench-js

Recursive file operations in Node.js
MIT License
435 stars 71 forks source link

rmdirRecursive fails to remove symbolic links #35

Closed brandonramirez closed 12 years ago

brandonramirez commented 12 years ago

The following code block from rmdirRecursive fails to act properly on symbolic links. The links get left behind, naturally causing rmdir to fail.

Changing stat to lstat fixes this because lstat is designed to return data about the link itself rather than the target of the link.

        fs.stat(file, function(err, stat){
            if (err) return clbk(err);
            if (stat.isDirectory())
                rmdirRecursive(file, rmFile);
            else
                fs.unlink(file, rmFile);
        });

change to

        fs.lstat(file, function(err, stat){
            if (err) return clbk(err);
            if (stat.isDirectory())
                rmdirRecursive(file, rmFile);
            else
                fs.unlink(file, rmFile);
        });
ryanmcgrath commented 12 years ago

Done. Thanks!