Skip to content

Commit 6b58b4b

Browse files
committed
Update: Report on readdir() errors #6610
1 parent 1a7a155 commit 6b58b4b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/csync/csync_update.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,21 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
712712
goto error;
713713
}
714714

715-
while ((dirent = csync_vio_readdir(ctx, dh))) {
715+
while (true) {
716+
// Get the next item in the directory
717+
errno = 0;
718+
dirent = csync_vio_readdir(ctx, dh);
719+
if (!dirent) {
720+
if (errno != 0) {
721+
// Note: Windows vio converts any error into EACCES
722+
qCWarning(lcUpdate, "readdir failed for file in %s - errno %d", uri, errno);
723+
goto error;
724+
}
725+
726+
// Normal case: End of items in directory
727+
break;
728+
}
729+
716730
/* Conversion error */
717731
if (dirent->path.isEmpty() && !dirent->original_path.isEmpty()) {
718732
ctx->status_code = CSYNC_STATUS_INVALID_CHARACTERS;

src/csync/vio/csync_vio_local_win.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ std::unique_ptr<csync_file_stat_t> csync_vio_local_readdir(csync_vio_handle_t *d
156156
// might be error, check!
157157
int dwError = GetLastError();
158158
if (dwError != ERROR_NO_MORE_FILES) {
159+
qCWarning(lcCSyncVIOLocal, "FindNextFile error %d", dwError);
159160
errno = EACCES; // no more files is fine. Otherwise EACCESS
160161
}
161162
return nullptr;

0 commit comments

Comments
 (0)