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;