diff --git a/src/csync.h b/src/csync.h index bd4da6d99a..2f9745efa8 100644 --- a/src/csync.h +++ b/src/csync.h @@ -129,7 +129,8 @@ enum csync_instructions_e { enum csync_ftw_type_e { CSYNC_FTW_TYPE_FILE, CSYNC_FTW_TYPE_SLINK, - CSYNC_FTW_TYPE_DIR + CSYNC_FTW_TYPE_DIR, + CSYNC_FTW_TYPE_IGNORE }; diff --git a/src/csync_update.c b/src/csync_update.c index c8977dca37..ec32b61d85 100644 --- a/src/csync_update.c +++ b/src/csync_update.c @@ -97,6 +97,12 @@ static int _csync_detect_update(CSYNC *ctx, const char *file, goto out; } + /* Ignore non statable files and other strange cases. */ + if (type == CSYNC_FTW_TYPE_IGNORE) { + st->instruction = CSYNC_INSTRUCTION_NONE; + goto out; + } + /* Update detection: Check if a database entry exists. * If not, the file is either new or has been renamed. To see if it is * renamed, the db gets queried by the inode of the file as that one @@ -195,36 +201,34 @@ out: int csync_walker(CSYNC *ctx, const char *file, const csync_vio_file_stat_t *fs, enum csync_ftw_flags_e flag) { + int rc = -1; + int type = CSYNC_FTW_TYPE_IGNORE; + switch (flag) { case CSYNC_FTW_FLAG_FILE: CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file: %s", file); - - return _csync_detect_update(ctx, file, fs, CSYNC_FTW_TYPE_FILE); + type = CSYNC_FTW_TYPE_FILE; break; - case CSYNC_FTW_FLAG_SLINK: - /* FIXME: implement support for symlinks, see csync_propagate.c too */ -#if 0 - if (ctx->options.sync_symbolic_links) { - CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "symlink: %s", file); - - return _csync_detect_update(ctx, file, fs, CSYNC_FTW_TYPE_SLINK); - } -#endif - break; - case CSYNC_FTW_FLAG_DIR: /* enter directory */ - CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "directory: %s", file); - - return _csync_detect_update(ctx, file, fs, CSYNC_FTW_TYPE_DIR); - case CSYNC_FTW_FLAG_NSTAT: /* not statable file */ - case CSYNC_FTW_FLAG_DNR: - case CSYNC_FTW_FLAG_DP: - case CSYNC_FTW_FLAG_SLN: - break; - default: + case CSYNC_FTW_FLAG_DIR: /* enter directory */ + CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "directory: %s", file); + type = CSYNC_FTW_TYPE_DIR; break; + case CSYNC_FTW_FLAG_SLINK: + CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "symlink: %s - not supported", file); + type = CSYNC_FTW_TYPE_IGNORE; + break; + case CSYNC_FTW_FLAG_NSTAT: /* not statable file */ + case CSYNC_FTW_FLAG_DNR: + case CSYNC_FTW_FLAG_DP: + case CSYNC_FTW_FLAG_SLN: + default: + CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file: %s non statable!", file); + type = CSYNC_FTW_TYPE_IGNORE; } - return 0; + rc = _csync_detect_update(ctx, file, fs, type ); + + return rc; } /* check if the dirent entries for the directory can be read from db diff --git a/src/vio/csync_vio.c b/src/vio/csync_vio.c index 946552b7db..fb4a48f7b7 100644 --- a/src/vio/csync_vio.c +++ b/src/vio/csync_vio.c @@ -552,8 +552,13 @@ int csync_vio_stat(CSYNC *ctx, const char *uri, csync_vio_file_stat_t *buf) { break; case LOCAL_REPLICA: rc = csync_vio_local_stat(uri, buf); + if (rc < 0) { + CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Local stat failed, errno %d", errno); + } #ifdef _WIN32 - CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "Win32: STAT-inode for %s: %llu", uri, buf->inode ); + else { + CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "Win32: STAT-inode for %s: %llu", uri, buf->inode ); + } #endif break; default: diff --git a/src/vio/csync_vio_local.c b/src/vio/csync_vio_local.c index f5bdc1e0f3..3e6a7b1f58 100644 --- a/src/vio/csync_vio_local.c +++ b/src/vio/csync_vio_local.c @@ -359,8 +359,7 @@ int csync_vio_local_stat(const char *uri, csync_vio_file_stat_t *buf) { HANDLE h = CreateFileW( wuri, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL+FILE_FLAG_BACKUP_SEMANTICS, NULL ); if( h == INVALID_HANDLE_VALUE ) { - DWORD err = GetLastError(); - /* CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "ERR: Failed to create a handle for %s: %ld", uri,err ); */ + errno = GetLastError(); csync_vio_file_stat_destroy(buf); c_free_multibyte(wuri); return -1;