Update: Report on readdir() errors #6610

This commit is contained in:
Christian Kamm 2018-06-26 13:36:20 +02:00 committed by Camila San
parent 23d64dd3ac
commit 3ec4fc6145
No known key found for this signature in database
GPG key ID: 7A4A6121E88E2AD4
2 changed files with 16 additions and 1 deletions

View file

@ -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;

View file

@ -156,6 +156,7 @@ std::unique_ptr<csync_file_stat_t> 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;