From 3ec4fc61453eaab66825c951be258d216b56eaa2 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Tue, 26 Jun 2018 13:36:20 +0200 Subject: [PATCH] Update: Report on readdir() errors #6610 --- src/csync/csync_update.cpp | 16 +++++++++++++++- src/csync/vio/csync_vio_local_win.cpp | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/csync/csync_update.cpp b/src/csync/csync_update.cpp index 6115357156..b1ed6674d0 100644 --- a/src/csync/csync_update.cpp +++ b/src/csync/csync_update.cpp @@ -663,7 +663,21 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn, goto error; } - while ((dirent = csync_vio_readdir(ctx, dh))) { + while (true) { + // Get the next item in the directory + errno = 0; + dirent = csync_vio_readdir(ctx, dh); + if (!dirent) { + if (errno != 0) { + // Note: Windows vio converts any error into EACCES + qCWarning(lcUpdate, "readdir failed for file in %s - errno %d", uri, errno); + goto error; + } + + // Normal case: End of items in directory + break; + } + /* Conversion error */ if (dirent->path.isEmpty() && !dirent->original_path.isEmpty()) { ctx->status_code = CSYNC_STATUS_INVALID_CHARACTERS; diff --git a/src/csync/vio/csync_vio_local_win.cpp b/src/csync/vio/csync_vio_local_win.cpp index 1c9a5907f3..d01a52a8cb 100644 --- a/src/csync/vio/csync_vio_local_win.cpp +++ b/src/csync/vio/csync_vio_local_win.cpp @@ -156,6 +156,7 @@ std::unique_ptr csync_vio_local_readdir(csync_vio_handle_t *d // might be error, check! int dwError = GetLastError(); if (dwError != ERROR_NO_MORE_FILES) { + qCWarning(lcCSyncVIOLocal, "FindNextFile error %d", dwError); errno = EACCES; // no more files is fine. Otherwise EACCESS } return nullptr;