Fix(lib/fs/tests): Avoid permission denials when cleaning up TempDirs in set_get_permissions_nofollows* - #160281
Open
PaulDance wants to merge 1 commit into
Conversation
… in `set_get_permissions_nofollows*`
At least under Windows 7, the `set_get_permissions_nofollows` and
`set_get_permissions_nofollows_symlink` FS tests currently fail on:
```
---- fs::tests::set_get_permissions_nofollows stdout ----
thread 'fs::tests::set_get_permissions_nofollows' (2308) panicked at library/std/src/test_helpers.rs:53:20:
called `Result::unwrap()` on an `Err` value: Os { code: 5, kind: PermissionDenied, message: "Access is denied." }
---- fs::tests::set_get_permissions_nofollows stdout end ----
---- fs::tests::set_get_permissions_nofollows_symlink stdout ----
thread 'fs::tests::set_get_permissions_nofollows_symlink' (1108) panicked at library/std/src/test_helpers.rs:53:20:
called `Result::unwrap()` on an `Err` value: Os { code: 5, kind: PermissionDenied, message: "Access is denied." }
---- fs::tests::set_get_permissions_nofollows_symlink stdout end ----
```
The panic clearly occurs in `TempDir::drop` that calls `fs::remove_dir_all`.
This is consistent with the fact that `FILE_ATTRIBUTE_READONLY` is set
on the file:
> Applications can read the file, but cannot write to it or delete it.
from [the attribute's documentation].
This therefore fixes these tests by resetting the attribute before
letting the drop guard run.
[the attribute's documentation]: https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants
Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
PaulDance
marked this pull request as ready for review
July 31, 2026 15:45
Collaborator
|
r? @clarfonthey rustbot has assigned @clarfonthey. Use Why was this reviewer chosen?The reviewer was selected based on:
|
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.
At least under Windows 7, the
set_get_permissions_nofollowsandset_get_permissions_nofollows_symlinkFS tests currently fail on:The panic clearly occurs in
TempDir::dropthat callsfs::remove_dir_all. This is consistent with the fact thatFILE_ATTRIBUTE_READONLYis set on the file:from the attribute's documentation.
This therefore fixes these tests by resetting the attribute before letting the drop guard run.
cc #141607 @roblabla
@rustbot label T-libs A-io O-windows