From c01d75d02651a33016ce47faea754447ccdad3db Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 19 May 2008 11:39:11 +0200 Subject: [PATCH] Split up the propagation visitor in file and dir propagator. --- src/csync_propagate.c | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/csync_propagate.c b/src/csync_propagate.c index d9c3baf2e1..4f33450f6e 100644 --- a/src/csync_propagate.c +++ b/src/csync_propagate.c @@ -367,7 +367,7 @@ static int csync_remove_dir(CSYNC *ctx, csync_file_stat_t *st) { return 0; } -static int csync_propagation_visitor(void *obj, void *data) { +static int csync_propagation_file_visitor(void *obj, void *data) { csync_file_stat_t *st = NULL; CSYNC *ctx = NULL; @@ -396,6 +396,33 @@ static int csync_propagation_visitor(void *obj, void *data) { break; } break; + case CSYNC_FTW_TYPE_DIR: + /* + * We have to walk over the files first. If you create or rename a file + * in a directory on unix. The modification time of the directory gets + * changed. + */ + break; + default: + break; + } + + return 0; +err: + CSYNC_LOG(CSYNC_LOG_PRIORITY_FATAL, "file: %s, error: %s", st->path, strerror(errno)); + return -1; +} + +static int csync_propagation_dir_visitor(void *obj, void *data) { + csync_file_stat_t *st = NULL; + CSYNC *ctx = NULL; + + st = (csync_file_stat_t *) obj; + ctx = (CSYNC *) data; + + switch(st->type) { + case CSYNC_FTW_TYPE_FILE: + break; case CSYNC_FTW_TYPE_DIR: switch (st->instruction) { case CSYNC_INSTRUCTION_NEW: @@ -409,11 +436,9 @@ static int csync_propagation_visitor(void *obj, void *data) { } break; case CSYNC_INSTRUCTION_REMOVE: - /* - * We have to remove after the propagation, - * when the files have been removed and the - * dirs are emtpy. - */ + if (csync_remove_dir(ctx, st) < 0) { + goto err; + } break; default: break; @@ -443,7 +468,11 @@ int csync_propapate_files(CSYNC *ctx) { break; } - if (c_rbtree_walk(tree, (void *) ctx, csync_propagation_visitor) < 0) { + if (c_rbtree_walk(tree, (void *) ctx, csync_propagation_file_visitor) < 0) { + return -1; + } + + if (c_rbtree_walk(tree, (void *) ctx, csync_propagation_dir_visitor) < 0) { return -1; }