Skip to content

Commit

Permalink
Treat EPERM as indicative of non-empty dir
Browse files Browse the repository at this point in the history
As per http://sourceforge.net/mailarchive/message.php?msg_id=31240176
sshfs-mounted directories return EPERM on rmdir called with non-empty
dir. Hence removing non-empty directories mounted through sshfs didn't
work with rimraf, and this change makes it work.
  • Loading branch information
jkozera authored and isaacs committed Jan 15, 2014
1 parent 843c29b commit bd19df7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rimraf.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function rmdir (p, originalEr, cb) {
// if we guessed wrong, and it's not a directory, then
// raise the original error.
fs.rmdir(p, function (er) {
if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST"))
if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM"))
rmkids(p, cb)
else if (er && er.code === "ENOTDIR")
cb(originalEr)
Expand Down Expand Up @@ -165,7 +165,7 @@ function rmdirSync (p, originalEr) {
return
if (er.code === "ENOTDIR")
throw originalEr
if (er.code === "ENOTEMPTY" || er.code === "EEXIST")
if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")
rmkidsSync(p)
}
}
Expand Down

0 comments on commit bd19df7

Please sign in to comment.