godirwalk icon indicating copy to clipboard operation
godirwalk copied to clipboard

fix: ignore EOF error on Windows directory scanning

Open powersj opened this issue 2 years ago • 5 comments

In #68, the scanner now returns any error that was encountered. On Windows, the call to Readdir will return an EOF when it is done reading a directory.

I believe the desired behavior is to throw an error on any actual errors, but in the case of EOF, continue on to the next directory. As such, check for the EOF and return no error while releasing resources.

A user can test this PR by using the walk-fast example:

go run ./examples/walk-fast/main.go --verbose C:/users/powersj/godirwalk

Currently, this will throw an EOF error after the first directory. With this fix, all the sub-directories will be traversed and return successfully.

fixes: #70

powersj avatar Jan 31 '23 19:01 powersj

Hmm the test error is:

The Go task failed with an error: Error: The process 'C:\hostedtoolcache\windows\go\1.13.0\x64\bin\go.exe' failed with exit code 2

This also appears on master currently, but error code 1.

Here is local running, with go1.19:

PS C:\Users\powersj\godirwalk> go test ./...
ok      github.com/karrick/godirwalk    0.187s
?       github.com/karrick/godirwalk/examples/remove-empty-directories  [no test files]
?       github.com/karrick/godirwalk/examples/scanner   [no test files]
?       github.com/karrick/godirwalk/examples/sizes     [no test files]
?       github.com/karrick/godirwalk/examples/walk-fast [no test files]
?       github.com/karrick/godirwalk/examples/walk-stdlib       [no test files]

powersj avatar Jan 31 '23 20:01 powersj

@xuyang2 thanks! seems to resolved the test failure as well :)

powersj avatar Feb 01 '23 01:02 powersj

@karrick anything I can do to help this along?

powersj avatar Feb 13 '23 20:02 powersj

@xuyang2 We're also interested in this fix - is there an estimate as to when this is going to be released?

N-o-Z avatar Aug 22 '23 09:08 N-o-Z

@karrick Is this project still active?

N-o-Z avatar Aug 22 '23 09:08 N-o-Z