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

ensure detection of entry type on windows is reliable #7068

Merged
merged 1 commit into from
Sep 5, 2024
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
11 changes: 6 additions & 5 deletions src/csync/vio/csync_vio_local_win.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/csync/vio/csync_vio_local_win.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/csync/vio/csync_vio_local_win.cpp

File src/csync/vio/csync_vio_local_win.cpp does not conform to Custom style guidelines. (lines 145, 160, 161, 163)
* libcsync -- a library to sync a directory with another
*
* Copyright (c) 2008-2013 by Andreas Schneider <[email protected]>
Expand Down Expand Up @@ -27,7 +27,7 @@

#include <memory>

#include "windows.h"

Check failure on line 30 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:30:10 [clang-diagnostic-error]

'windows.h' file not found

#include "c_private.h"
#include "c_lib.h"
Expand Down Expand Up @@ -142,9 +142,11 @@
file_stat = std::make_unique<csync_file_stat_t>();
file_stat->path = path.toUtf8();

mgallien marked this conversation as resolved.
Show resolved Hide resolved
const auto isDirectory = handle->ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;

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

Check warning on line 147 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:147: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) && !isDirectory) {
// 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,11 +157,10 @@
// 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) &&
!isDirectory) {
file_stat->type = ItemTypeSkip;
} else if (handle->ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
} else if (isDirectory) {
file_stat->type = ItemTypeDirectory;
} else {
file_stat->type = ItemTypeFile;
Expand Down
Loading