-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Walk
from ignore
returns an Ok(...) and an Err(...) for the same permission-denied subdirectory
#953
Comments
TL;DR - This looks like expected behavior to me. Thanks for the good bug report though!
It's a bit more subtle than that. When you list the contents of
The The documentation on the |
Gotcha - thanks so much for the detailed response! Glad to hear this is expected. In that case, I'll build a workaround. Shouldn't be a big deal! Just for my own clarity - were you asking for help improving the docs on the Thanks again! |
Actually, suggestions from you would be far more useful than what I could come up with. You're the one using the crate, and you understand your use far better than I do. :-) You don't have to submit a PR or anything, but if you did want to help, just leaving some suggestions for things to include in the doc string would be much appreciated! Submitting a PR would be fine, and of course, doing nothing is fine too. :-) I will come up with something. |
Ok - sounds good! I'm happy to come up with some ideas. I'll keep you posted! |
Having read a little deeper, it seems like the only time If that is the case, it's not clear to me that there's a lot to be added to the docstring for I think my confusion came from the ambiguity inherent in "An example of an error is...". If the only errors are ignore parsing errors, maybe the docstring could be more explicit about that? Unless I misread, of course. In that case, if the set of errors is still relatively discrete maybe the docstring could enumerate them, or say something more along the lines of "This method is intended for detecting that parsing an Re: the fact that Thanks again for your help! |
@sashaweiss The issue here is that I don't want to say, "this will only ever produce /// Returns an error, if one exists, associated with processing this entry.
///
/// An example of an error is one that occurred while parsing an ignore
/// file. Errors related to traversing a directory tree itself are reported
/// as part of yielding the directory entry, and not with this method.
|
Awesome - thanks @BurntSushi! |
Skipped some of the preamble, since this isn't strictly a
ripgrep
question!I'm using
ignore 0.4.2
, on Mac OSX 10.13.4.Describe your question, feature request, or bug.
When I use a
Walk
to iterate a directory containing a subdirectory with restricted permissions, it yields two separate entries for that subdirectory - one with anOk(DirEntry {...})
and one with anErr(WithPath {...})
.Also interestingly, calling the
DirEntry::error()
method from theDirEntry
in theOk
returnsNone
.If this is a bug, what are the steps to reproduce the behavior?
This example repo will demonstrate this behavior!
If this is a bug, what is the expected behavior?
I think I expected that calling
DirEntry::error()
on theDirEntry {...}
in theOk
would give me back the sameWithPath
error, or some other indicator thatignore
won't be able to recur into that directory.Alternatively, if it's possible for a
Walk
to build aDirEntry
even for a directory that is permission-restricted, maybe it makes sense for there to be anotherError
variant that contains aDirEntry
? AWithDirEntry {...}
perhaps?I think in either case it'd make sense to eliminate the duplicate entry - in the first case by not returning the
Err
, and in the second case by not returning theOk
. Off the bat, not sure which would make the most sense. It's also not immediately clear to me how to make sure a solution to this makes sense for permission-restricted files, since so far my discussion of it has been focused on directories (and the fact thatignore
won't recur into them).My intuition says that the error comes about since
ignore
can detect the restricted directory while searching its parent directory, and that the error comes about when it tries to dive in - since this doesn't come up for restricted files. If you agree that this is something that should change, I'd be happy to try to help with a PR if you'd like!Thanks in advance for your advice!
ignore
has been awesome to use and exactly what I needed - just want to confirm this behavior with you before building a workaround.The text was updated successfully, but these errors were encountered: