Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore EOF error on Windows directory scanning #71

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

powersj
Copy link

@powersj powersj commented Jan 31, 2023

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

In karrick#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.

fixes: karrick#70
@powersj
Copy link
Author

powersj commented Jan 31, 2023

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
Copy link
Author

powersj commented Feb 1, 2023

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

@powersj
Copy link
Author

powersj commented Feb 13, 2023

@karrick anything I can do to help this along?

@N-o-Z
Copy link

N-o-Z commented Aug 22, 2023

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

@N-o-Z
Copy link

N-o-Z commented Aug 22, 2023

@karrick Is this project still active?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

walk EOF error on Windows
3 participants