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

Deflake directory iterator for windows #24469

Merged
merged 3 commits into from
Dec 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion source/common/filesystem/win32/directory_iterator_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ DirectoryIteratorImpl& DirectoryIteratorImpl::operator++() {
}

DirectoryEntry DirectoryIteratorImpl::makeEntry(const WIN32_FIND_DATA& find_data) {
// `IO_REPARSE_FLAG_SYMLINK` must only be used in conjunction with
// `FILE_ATTRIBUTE_REPARSE_POINT`, per documentation for `dwReserved0` at
// https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-win32_find_dataa
if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
!(find_data.dwReserved0 & IO_REPARSE_TAG_SYMLINK)) {
// The file is reparse point and not a symlink, so it can't be
// a regular file or a directory
return {std::string(find_data.cFileName), FileType::Other, absl::nullopt};
} else if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
return {std::string(find_data.cFileName), FileType::Directory, absl::nullopt};
} else if (find_data.dwReserved0 & IO_REPARSE_TAG_SYMLINK) {
} else if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add the link from the description into the source code here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

(find_data.dwReserved0 & IO_REPARSE_TAG_SYMLINK)) {
return {std::string(find_data.cFileName), FileType::Regular, absl::nullopt};
} else {
ULARGE_INTEGER file_size;
Expand Down