mirror of
https://github.com/minio/minio.git
synced 2024-12-25 06:35:56 -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{}
|
data := &syscall.Win32finddata{}
|
||||||
handle, err := syscall.FindFirstFile(globAllP, data)
|
handle, err := syscall.FindFirstFile(globAllP, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Fails on file not found and when not a directory.
|
if err = syscallErrToFileErr(dirPath, err); err == errFileNotFound {
|
||||||
return errFileNotFound
|
return nil
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
defer syscall.CloseHandle(handle)
|
defer syscall.CloseHandle(handle)
|
||||||
|
|
||||||
@ -123,9 +125,9 @@ func readDirWithOpts(dirPath string, opts readDirOpts) (entries []string, err er
|
|||||||
data := &syscall.Win32finddata{}
|
data := &syscall.Win32finddata{}
|
||||||
handle, err := syscall.FindFirstFile(globAllP, data)
|
handle, err := syscall.FindFirstFile(globAllP, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Fails on file not found and when not a directory.
|
return nil, syscallErrToFileErr(dirPath, err)
|
||||||
return nil, errFileNotFound
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defer syscall.CloseHandle(handle)
|
defer syscall.CloseHandle(handle)
|
||||||
|
|
||||||
count := opts.count
|
count := opts.count
|
||||||
@ -181,3 +183,21 @@ func readDirWithOpts(dirPath string, opts readDirOpts) (entries []string, err er
|
|||||||
func globalSync() {
|
func globalSync() {
|
||||||
// no-op on windows
|
// 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