Skip to content

Commit

Permalink
ensure detection of entry type on windows is reliable
Browse files Browse the repository at this point in the history
it seems that there is a possibility for the type detection to report a
folder as being a file

with this change, I am pretty sure that cannot happen any longer

Signed-off-by: Matthieu Gallien <[email protected]>
  • Loading branch information
mgallien committed Sep 3, 2024
1 parent 07e873c commit 348f31e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/csync/vio/csync_vio_local_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ std::unique_ptr<csync_file_stat_t> csync_vio_local_readdir(csync_vio_handle_t *h

if (vfs && vfs->statTypeVirtualFile(file_stat.get(), &handle->ffd)) {

Check warning on line 145 in src/csync/vio/csync_vio_local_win.cpp

View workflow job for this annotation

GitHub Actions / build

src/csync/vio/csync_vio_local_win.cpp:145:73 [bugprone-branch-clone]

repeated branch in conditional chain
// all good
} else if (handle->ffd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
} else if ((handle->ffd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) && !(handle->ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
// Detect symlinks, and treat junctions as symlinks too.
if (handle->ffd.dwReserved0 == IO_REPARSE_TAG_SYMLINK
|| handle->ffd.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT) {
Expand All @@ -155,9 +155,8 @@ std::unique_ptr<csync_file_stat_t> csync_vio_local_readdir(csync_vio_handle_t *h
// but will also treat them normally for now.
file_stat->type = ItemTypeFile;
}
} else if (handle->ffd.dwFileAttributes & FILE_ATTRIBUTE_DEVICE
|| handle->ffd.dwFileAttributes & FILE_ATTRIBUTE_OFFLINE
) {
} else if ((handle->ffd.dwFileAttributes & FILE_ATTRIBUTE_DEVICE || handle->ffd.dwFileAttributes & FILE_ATTRIBUTE_OFFLINE) &&
!(handle->ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
file_stat->type = ItemTypeSkip;
} else if (handle->ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
file_stat->type = ItemTypeDirectory;
Expand Down

0 comments on commit 348f31e

Please sign in to comment.