Skip to content

Commit f72eb47

Browse files
committed
Add another error to Windows file open fallback
Added another error to be processed in fallback Solution suggested by Chris Denton nushell/nushell#6857 (comment)
1 parent 96834f0 commit f72eb47

File tree

1 file changed

+6
-1
lines changed
  • library/std/src/sys/windows

1 file changed

+6
-1
lines changed

Diff for: library/std/src/sys/windows/fs.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,12 @@ fn metadata(path: &Path, reparse: ReparsePoint) -> io::Result<FileAttr> {
12661266
// If the fallback fails for any reason we return the original error.
12671267
match File::open(path, &opts) {
12681268
Ok(file) => file.file_attr(),
1269-
Err(e) if e.raw_os_error() == Some(c::ERROR_SHARING_VIOLATION as _) => {
1269+
Err(e)
1270+
if [Some(c::ERROR_SHARING_VIOLATION as _), Some(c::ERROR_ACCESS_DENIED as _)]
1271+
.contains(&e.raw_os_error()) =>
1272+
{
1273+
// `ERROR_ACCESS_DENIED` is returned when the user doesn't have permission for the resource.
1274+
// One such example is `System Volume Information` as default but can be created as well
12701275
// `ERROR_SHARING_VIOLATION` will almost never be returned.
12711276
// Usually if a file is locked you can still read some metadata.
12721277
// However, there are special system files, such as

0 commit comments

Comments
 (0)