mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
Fix crash on Windows when crawling (#10385)
* readDirN: Check if file is directory
`syscall.FindNextFile` crashes if the handle is a file.
`errFileNotFound` matches 'unix' functionality: d19b434ffc/cmd/os-readdir_unix.go (L106)
Fixes #10384
This commit is contained in:
parent
4b6585d249
commit
1c085f7d1a
@ -19,6 +19,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
@ -79,10 +80,16 @@ func readDirN(dirPath string, count int) (entries []string, err error) {
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
// Check if file or dir. This is the quickest way.
|
||||
_, err = f.Seek(0, io.SeekStart)
|
||||
if err == nil {
|
||||
return nil, errFileNotFound
|
||||
}
|
||||
data := &syscall.Win32finddata{}
|
||||
handle := syscall.Handle(f.Fd())
|
||||
|
||||
for count != 0 {
|
||||
e := syscall.FindNextFile(syscall.Handle(f.Fd()), data)
|
||||
e := syscall.FindNextFile(handle, data)
|
||||
if e != nil {
|
||||
if e == syscall.ERROR_NO_MORE_FILES {
|
||||
break
|
||||
|
Loading…
Reference in New Issue
Block a user