mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-25 05:45:42 +03:00
Handle non statable files gracefully.
This commit is contained in:
parent
089d919be2
commit
d943b2880a
4 changed files with 36 additions and 27 deletions
|
@ -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
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue