mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
os/windows: do not return errFileNotFound in readDir's (#16988)
This commit is contained in:
parent
d3f70ea340
commit
260a63ca73
@ -48,8 +48,10 @@ func readDirFn(dirPath string, filter func(name string, typ os.FileMode) error)
|
||||
data := &syscall.Win32finddata{}
|
||||
handle, err := syscall.FindFirstFile(globAllP, data)
|
||||
if err != nil {
|
||||
// Fails on file not found and when not a directory.
|
||||
return errFileNotFound
|
||||
if err = syscallErrToFileErr(dirPath, err); err == errFileNotFound {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
defer syscall.CloseHandle(handle)
|
||||
|
||||
@ -123,9 +125,9 @@ func readDirWithOpts(dirPath string, opts readDirOpts) (entries []string, err er
|
||||
data := &syscall.Win32finddata{}
|
||||
handle, err := syscall.FindFirstFile(globAllP, data)
|
||||
if err != nil {
|
||||
// Fails on file not found and when not a directory.
|
||||
return nil, errFileNotFound
|
||||
return nil, syscallErrToFileErr(dirPath, err)
|
||||
}
|
||||
|
||||
defer syscall.CloseHandle(handle)
|
||||
|
||||
count := opts.count
|
||||
@ -181,3 +183,21 @@ func readDirWithOpts(dirPath string, opts readDirOpts) (entries []string, err er
|
||||
func globalSync() {
|
||||
// no-op on windows
|
||||
}
|
||||
|
||||
func syscallErrToFileErr(dirPath string, err error) error {
|
||||
switch err {
|
||||
case nil:
|
||||
return nil
|
||||
case syscall.ERROR_FILE_NOT_FOUND:
|
||||
return errFileNotFound
|
||||
case syscall.ERROR_ACCESS_DENIED:
|
||||
return errFileAccessDenied
|
||||
default:
|
||||
// Fails on file not found and when not a directory.
|
||||
return osErrToFileErr(&os.PathError{
|
||||
Op: "FindNextFile",
|
||||
Path: dirPath,
|
||||
Err: err,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user