Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error from reading a directory without permission doesn't give path #126

Open
metsuke0 opened this issue Jul 26, 2019 · 2 comments
Open

Comments

@metsuke0
Copy link

metsuke0 commented Jul 26, 2019

When iterating over the WalkDir dictionary in Windows 10, rust stable 1.36, if the user does not have permission to read a directory, an error is given, but not the actual path. When hitting an error with files, the path in the error is displayed but not with directories for some reason:

Error on entry 'Err(Error { depth: 2, inner: Io { path: None, err: Os { code: 5, kind: PermissionDenied, message: "Access is denied." } } })': Error { depth: 2, inner: Io { path: None, err: Os { code: 5, kind: PermissionDenied, message: "Access is denied." } } }

    for entry in WalkDir::new(some_path){
        prepath = match &entry {
            Ok(path) => { 
                path
            }
            Err(err) => {
                println!("Error on entry '{:?}': {:?}", entry, err);             
                continue
            }
        };
@BurntSushi
Copy link
Owner

Hmm, I can't reproduce this on Linux. It will probably be a while before I will debug this on Windows. Others are welcome to investigate and look for a fix sooner.

@selfup
Copy link

selfup commented Aug 13, 2019

Yep same here. If I can find some time I'll poke around.

I ran into the same issues with Go/JS. Windows is just really stubborn with this kind of stuff.

Once I get a good entry I get some of those Os errors to when calling fs::metadata.

Even if the permission is correct I do get errors like:

Os { code: 3, kind: NotFound, message: "The system cannot find the path specified." }

and

Os { code: 1920, kind: Other, message: "The file cannot be accessed by the system." }

So I do believe it's mostly a Windows issue.


Here is my code in a repo but it is pretty much the same as above: https://github.com/selfup/win42/blob/master/src/main.rs#L37


However on the unwrap sometimes you get a Some with the path!

Error {
    depth: 21,
    inner: Io {
      path: Some("C:/Users\\selfup\\AppData\\Roaming\\REDACTED"),
      err: Os {
          code: 3,
          kind: NotFound,
          message: "The system cannot find the path specified."
       }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants