csync_update: Handling hidden files as excluded files, as intended.

This commit is contained in:
Klaas Freitag 2015-07-08 18:06:38 +02:00
parent e0abbc0b83
commit 7aa2b50828
4 changed files with 29 additions and 22 deletions

View file

@ -103,7 +103,8 @@ enum csync_status_codes_e {
CSYNC_STATUS_INDIVIDUAL_IGNORE_LIST, CSYNC_STATUS_INDIVIDUAL_IGNORE_LIST,
CSYNC_STATUS_INDIVIDUAL_IS_INVALID_CHARS, CSYNC_STATUS_INDIVIDUAL_IS_INVALID_CHARS,
CSYNC_STATUS_INDIVIDUAL_EXCLUDE_LONG_FILENAME, CSYNC_STATUS_INDIVIDUAL_EXCLUDE_LONG_FILENAME,
CYSNC_STATUS_FILE_LOCKED_OR_OPEN CYSNC_STATUS_FILE_LOCKED_OR_OPEN,
CSYNC_STATUS_INDIVIDUAL_EXCLUDE_HIDDEN
}; };
typedef enum csync_status_codes_e CSYNC_STATUS; typedef enum csync_status_codes_e CSYNC_STATUS;

View file

@ -27,7 +27,8 @@ enum csync_exclude_type_e {
CSYNC_FILE_EXCLUDE_AND_REMOVE, CSYNC_FILE_EXCLUDE_AND_REMOVE,
CSYNC_FILE_EXCLUDE_LIST, CSYNC_FILE_EXCLUDE_LIST,
CSYNC_FILE_EXCLUDE_INVALID_CHAR, CSYNC_FILE_EXCLUDE_INVALID_CHAR,
CSYNC_FILE_EXCLUDE_LONG_FILENAME CSYNC_FILE_EXCLUDE_LONG_FILENAME,
CSYNC_FILE_EXCLUDE_HIDDEN
}; };
typedef enum csync_exclude_type_e CSYNC_EXCLUDE_TYPE; typedef enum csync_exclude_type_e CSYNC_EXCLUDE_TYPE;

View file

@ -163,29 +163,29 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
len = strlen(path); len = strlen(path);
/* This code should probably be in csync_exclude, but it does not have the fs parameter.
Keep it here for now and TODO also find out if we want this for Windows
https://github.com/owncloud/mirall/issues/2086 */
if (fs->flags & CSYNC_VIO_FILE_FLAGS_HIDDEN) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file excluded because it is a hidden file: %s", path);
return 0;
}
/* Check if file is excluded */ /* Check if file is excluded */
excluded = csync_excluded(ctx, path,type); excluded = csync_excluded(ctx, path,type);
if (excluded != CSYNC_NOT_EXCLUDED) { if (excluded != CSYNC_NOT_EXCLUDED) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "%s excluded (%d)", path, excluded); CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "%s excluded (%d)", path, excluded);
if (excluded == CSYNC_FILE_EXCLUDE_AND_REMOVE) { if (excluded == CSYNC_FILE_EXCLUDE_AND_REMOVE) {
return 1; return 1;
} }
if (excluded == CSYNC_FILE_SILENTLY_EXCLUDED) { if (excluded == CSYNC_FILE_SILENTLY_EXCLUDED) {
return 1; return 1;
} }
if (ctx->current_fs) { if (ctx->current_fs) {
ctx->current_fs->has_ignored_files = true; ctx->current_fs->has_ignored_files = true;
} }
} else {
/* This code should probably be in csync_exclude, but it does not have the fs parameter.
Keep it here for now */
if (fs->flags & CSYNC_VIO_FILE_FLAGS_HIDDEN) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file excluded because it is a hidden file: %s", path);
excluded = CSYNC_FILE_EXCLUDE_HIDDEN;
}
} }
if (ctx->current == REMOTE_REPLICA && ctx->callbacks.checkSelectiveSyncBlackListHook) { if (ctx->current == REMOTE_REPLICA && ctx->callbacks.checkSelectiveSyncBlackListHook) {
@ -208,9 +208,9 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
st->child_modified = 0; st->child_modified = 0;
st->has_ignored_files = 0; st->has_ignored_files = 0;
/* check hardlink count */ /* FIXME: Under which conditions are the following two ifs true and the code
* is executed? */
if (type == CSYNC_FTW_TYPE_FILE ) { if (type == CSYNC_FTW_TYPE_FILE ) {
if (fs->mtime == 0) { if (fs->mtime == 0) {
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file: %s - mtime is zero!", path); CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file: %s - mtime is zero!", path);
@ -424,6 +424,8 @@ out:
st->error_status = CSYNC_STATUS_INDIVIDUAL_IS_INVALID_CHARS; /* File contains invalid characters. */ st->error_status = CSYNC_STATUS_INDIVIDUAL_IS_INVALID_CHARS; /* File contains invalid characters. */
} else if (excluded == CSYNC_FILE_EXCLUDE_LONG_FILENAME) { } else if (excluded == CSYNC_FILE_EXCLUDE_LONG_FILENAME) {
st->error_status = CSYNC_STATUS_INDIVIDUAL_EXCLUDE_LONG_FILENAME; /* File name is too long. */ st->error_status = CSYNC_STATUS_INDIVIDUAL_EXCLUDE_LONG_FILENAME; /* File name is too long. */
} else if (excluded == CSYNC_FILE_EXCLUDE_HIDDEN ) {
st->error_status = CSYNC_STATUS_INDIVIDUAL_EXCLUDE_HIDDEN;
} }
} }
if (st->instruction != CSYNC_INSTRUCTION_NONE && st->instruction != CSYNC_INSTRUCTION_IGNORE if (st->instruction != CSYNC_INSTRUCTION_NONE && st->instruction != CSYNC_INSTRUCTION_IGNORE

View file

@ -376,6 +376,9 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
case CSYNC_STATUS_INDIVIDUAL_EXCLUDE_LONG_FILENAME: case CSYNC_STATUS_INDIVIDUAL_EXCLUDE_LONG_FILENAME:
item->_errorString = tr("Filename is too long."); item->_errorString = tr("Filename is too long.");
break; break;
case CSYNC_STATUS_INDIVIDUAL_EXCLUDE_HIDDEN:
item->_errorString = tr("File is ignored because it's hidden.");
break;
case CYSNC_STATUS_FILE_LOCKED_OR_OPEN: case CYSNC_STATUS_FILE_LOCKED_OR_OPEN:
item->_errorString = QLatin1String("File locked"); // don't translate, internal use! item->_errorString = QLatin1String("File locked"); // don't translate, internal use!
break; break;