filerjs / filer

Node-like file system for browsers
BSD 2-Clause "Simplified" License
621 stars 154 forks source link

fs.readdir() doesn't seem to error when dir path portion(s) are missing #365

Closed humphd closed 9 years ago

humphd commented 9 years ago
var fs = Bramble.getFileSystem()
undefined
var sh = new fs.Shell()
undefined
fs.readdir("/", function(err, entries) { console.log(err, entries); });
undefined
VM2193:2 null ["7", ".anonymous"]
fs.readdir("/.anonymous/projects/2550c589-4225-45c6-94f7-299af7f0886d", function(err, entries) {console.log(err, entries);});
undefined
VM2194:2 null ["crown.svg", "index.html", "style.css", "thimble.svg", "tutorial.html"]
sh.rm("/.anonymous/projects/2550c589-4225-45c6-94f7-299af7f0886d", {recursive:true}, function(err){console.log('err', err);})
undefined
VM2539:2 err null
fs.readdir("/.anonymous/projects/2550c589-4225-45c6-94f7-299af7f0886d", function(err, entries) {console.log(err, entries);});
undefined
fs.stat("/.anonymous/projects/2550c589-4225-45c6-94f7-299af7f0886d", function(err, entries) {console.log(err, entries);});
undefined
VM2540:2 e {name: "ENOENT", code: "ENOENT", errno: 34, message: "no such file or directory", path: "/.anonymous/projects/2550c589-4225-45c6-94f7-299af7f0886d"…} undefined

The stat call shows the failure, but the readdir doesn't get an error for some reason.

modeswitch commented 9 years ago

sh.rm is async, could this be a race?

humphd commented 9 years ago

Indeed, that's highly possible, and would explain why this might happen. I looked over the readdir code last night and it looked solid. I'll close and re-file if I hit it in proper code (this was just testing something in console).