-
Notifications
You must be signed in to change notification settings - Fork 170
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
ServeDir: convert io::ErrorKind::NotADirectory to not_found #331
Conversation
Shouldn't this be gated to unix oses? |
Yep, you're absolutely right, I missed that the code definition I was referring to came from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks looks good to me, I wonder if it's worth adding a comment to the ServeDir service highlighting this platform specific difference
You mean in the documentation? |
Yes exactly |
I added a short sentence where I believ it could fit |
Not sure what you mean by sys, but the raw os code is specific for each os; on windows error code 20 doesn't have the same meaning as ENOTDIR. Also, you could probably clean up your implementation a bit with https://doc.rust-lang.org/std/macro.cfg.html, since that looks like what you are trying to emulate with attribute macros. |
Motivation
In docs.rs we were seeing server errors on requests like
/-/static/index.js/979790
whenindex.js
actually existed.The error we are seeing was: "Not a directory (os error 20)".
Solution
If I'm not missing something this should be a "not found" error.
I'm not 100% certain if accessing
raw_os_error
is good enough here, butErrorKind::NotADirectory
is not on stable yet (seeio_error_more
).Since this is coming from libc I assume this is portable.I'm happy to add any needed changes, to close this if you disagree with my solution.