-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Directory.Delete: prefer DirectoryNotFoundException over UnauthorizedAccess IOException. #62396
Conversation
…Access IOException.
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsFixes #62034. @danmoseley @carlossanlop @adamsitnik ptal.
|
Can you trigger the outerloop/elevated testing? |
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 for your help, @tmds.
case Interop.Error.EROFS: | ||
// Prefer throwing DirectoryNotFoundException over UnauthorizedAccess IOException. | ||
if (topLevel && !DirectoryExists(fullPath, out Interop.ErrorInfo existErr) && existErr.Error == Interop.Error.ENOENT) | ||
{ | ||
throw Interop.GetExceptionForIoErrno(Interop.Error.ENOENT.Info(), fullPath, isDirectory: true); | ||
} | ||
throw new IOException(SR.Format(SR.UnauthorizedAccess_IODenied_Path, fullPath)); | ||
case Interop.Error.EISDIR: | ||
throw new IOException(SR.Format(SR.UnauthorizedAccess_IODenied_Path, fullPath)); // match Win32 exception | ||
throw new IOException(SR.Format(SR.UnauthorizedAccess_IODenied_Path, fullPath)); |
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.
Interesting case. The fix looks good but I have a few questions.
So you found that when EROFS is caught, there is a special case where the actual problem was that the top level directory didn't exist. Correct? Do we know what is the actual reason why EROFS is being returned and not something else?
Do you mind changing that comment to something that would describe that we have two different possible cases here? That would be more meaningful.
In the original issue, Dan left a comment asking if the elevated test was not being executed in the PR CI. Can you please verify that the test was indeed executed in this PR?
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.
So you found that when EROFS is caught, there is a special case where the actual problem was that the top level directory didn't exist. Correct? Do we know what is the actual reason why EROFS is being returned and not something else?
Previously we were always checking if the directory existed before trying to remove it.
One of the test verified that DirectoryNotFoundException
was thrown in favor of the UnauthorizedAccess_IODenied_Path
(on EROFS
). And I regressed it in #59520.
In the original issue, Dan left a comment asking if the elevated test was not being executed in the PR CI. Can you please verify that the test was indeed executed in this PR?
I'll verify the test passes.
@safern I've never done this. Do you know how to trigger it? Edit: Nevermind. Found the instructions 😃 |
/azp list |
This comment has been minimized.
This comment has been minimized.
/azp runtime-libraries-coreclr outerloop |
This comment has been minimized.
This comment has been minimized.
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs
Outdated
Show resolved
Hide resolved
@safern I see this failure --
|
Thanks, @danmoseley, I just logged: #62471 and retried the leg. I'll try to repro locally and fix that issue. |
@carlossanlop @danmoseley @jozkee I'll be making some changes. No need to do another review yet. |
8318ce5
to
6a4ebc7
Compare
This is up for review. I verified |
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.
LGTM, thank you @tmds!
Fixes #62034.
Regression in #59520.
@danmoseley @carlossanlop @adamsitnik ptal.