mirror of
https://github.com/pgsty/minio.git
synced 2026-07-24 22:46:16 +03: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: https://github.com/minio/minio/blob/d19b434ffceb005d0673c53bf28209559a536ed3/cmd/os-readdir_unix.go#L106 Fixes #10384
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
@@ -79,10 +80,16 @@ func readDirN(dirPath string, count int) (entries []string, err error) {
|
|||||||
}
|
}
|
||||||
defer f.Close()
|
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{}
|
data := &syscall.Win32finddata{}
|
||||||
|
handle := syscall.Handle(f.Fd())
|
||||||
|
|
||||||
for count != 0 {
|
for count != 0 {
|
||||||
e := syscall.FindNextFile(syscall.Handle(f.Fd()), data)
|
e := syscall.FindNextFile(handle, data)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
if e == syscall.ERROR_NO_MORE_FILES {
|
if e == syscall.ERROR_NO_MORE_FILES {
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user