rmdirRecursive fails to remove symbolic links #35

Closed
opened 2012-09-18 10:47:32 -07:00 by brandonramirez · 1 comment
brandonramirez commented 2012-09-18 10:47:32 -07:00 (Migrated from github.com)

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);
        });
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 2012-11-09 02:12:11 -08:00 (Migrated from github.com)

Done. Thanks!

Done. Thanks!
This repository is archived. You cannot comment on issues.
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: code/wrench-js#35
No description provided.