Do not report a move that succeeded as failed - #840
Merged
Conversation
Accepting a tracked move removes the directory the received file sat in when nothing is left in it, which is tidying up after a move that has already happened. Only IOException was caught there, so a directory whose parent will not have it removed threw UnauthorizedAccessException out of the accept - EACCES from rmdir, which .NET reports as that rather than as an IO error. The caller reads a throw as the move having failed, so the entry went back on the queue with an error on it, and the retry then failed with file not found: the temp file had been moved by the attempt that "failed". The enumerate is inside the guard too now, since it can refuse for the same reason. The test for it is Unix only. A read-only directory on Windows raises IOException, which was always caught, so the case cannot be reached there.
The test made the whole temp directory read only, so the move could not write its target either and failed for the reason the test was meant to rule out. The received file is two deep now and only the directory holding it is locked, so everything the move itself does stays permitted and the only thing denied is the removal after it. TUnit's own RunOn does the platform restriction, which the rest of the suite already uses.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Accepting a tracked move removes the directory the received file sat in when
nothing is left in it, which is tidying up after a move that has already happened.
Only IOException was caught there, so a directory whose parent will not have it
removed threw UnauthorizedAccessException out of the accept - EACCES from rmdir,
which .NET reports as that rather than as an IO error.
The caller reads a throw as the move having failed, so the entry went back on the
queue with an error on it, and the retry then failed with file not found: the temp
file had been moved by the attempt that "failed". The enumerate is inside the guard
too now, since it can refuse for the same reason.
The test for it is Unix only. A read-only directory on Windows raises IOException,
which was always caught, so the case cannot be reached there.