mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Add another error to Windows file open fallback
Added another error to be processed in fallback Solution suggested by Chris Denton https://github.com/nushell/nushell/issues/6857#issuecomment-1426847135
This commit is contained in:
parent
96834f0231
commit
f72eb4704a
@ -1266,7 +1266,12 @@ fn metadata(path: &Path, reparse: ReparsePoint) -> io::Result<FileAttr> {
|
||||
// If the fallback fails for any reason we return the original error.
|
||||
match File::open(path, &opts) {
|
||||
Ok(file) => file.file_attr(),
|
||||
Err(e) if e.raw_os_error() == Some(c::ERROR_SHARING_VIOLATION as _) => {
|
||||
Err(e)
|
||||
if [Some(c::ERROR_SHARING_VIOLATION as _), Some(c::ERROR_ACCESS_DENIED as _)]
|
||||
.contains(&e.raw_os_error()) =>
|
||||
{
|
||||
// `ERROR_ACCESS_DENIED` is returned when the user doesn't have permission for the resource.
|
||||
// One such example is `System Volume Information` as default but can be created as well
|
||||
// `ERROR_SHARING_VIOLATION` will almost never be returned.
|
||||
// Usually if a file is locked you can still read some metadata.
|
||||
// However, there are special system files, such as
|
||||
|
Loading…
Reference in New Issue
Block a user