From ce94beb06851c9954478fcdb7f401d37d5a7fb35 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 5 Dec 2012 18:10:46 +0100 Subject: [PATCH] Only refresh the folder id for remote replica Also don't remove trailing slash, there is no trailing slashes in the path --- src/csync.c | 1 - src/csync_private.h | 1 - src/csync_propagate.c | 46 +++++++++++-------------------------------- 3 files changed, 12 insertions(+), 36 deletions(-) diff --git a/src/csync.c b/src/csync.c index 807efc5d6..283d72db1 100644 --- a/src/csync.c +++ b/src/csync.c @@ -708,7 +708,6 @@ int csync_destroy(CSYNC *ctx) { /* free memory */ c_rbtree_free(ctx->local.tree); c_list_free(ctx->local.list); - c_list_free(ctx->local.id_list); c_rbtree_free(ctx->remote.tree); c_list_free(ctx->remote.list); c_list_free(ctx->remote.id_list); diff --git a/src/csync_private.h b/src/csync_private.h index f8851a84e..0d53b335a 100644 --- a/src/csync_private.h +++ b/src/csync_private.h @@ -98,7 +98,6 @@ struct csync_s { char *uri; c_rbtree_t *tree; c_list_t *list; - c_list_t *id_list; enum csync_replica_e type; } local; diff --git a/src/csync_propagate.c b/src/csync_propagate.c index bdbd9f415..40d58a5aa 100644 --- a/src/csync_propagate.c +++ b/src/csync_propagate.c @@ -50,22 +50,12 @@ static int _csync_cleanup_cmp(const void *a, const void *b) { static void _store_id_update(CSYNC *ctx, csync_file_stat_t *st) { c_list_t *list = NULL; + CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "SYNCED remember dir: %s", st->path); - switch (ctx->current) { - case LOCAL_REPLICA: - list = c_list_prepend(ctx->local.id_list, (void*)st); - if( list != NULL ) { - ctx->local.id_list = list; - } - break; - case REMOTE_REPLICA: - list = c_list_prepend(ctx->remote.id_list, (void*)st); - if(list != NULL ) { - ctx->remote.id_list = list; - } - break; - + list = c_list_prepend(ctx->remote.id_list, (void*)st); + if( list != NULL ) { + ctx->remote.id_list = list; } } @@ -1115,21 +1105,13 @@ static int _csync_correct_id(CSYNC *ctx) { const char *replica = NULL; char *path = NULL; - switch (ctx->current) { - case LOCAL_REPLICA: - list = ctx->local.id_list; - tree = ctx->local.tree; - replica = "LOCAL_REPLICA"; - break; - case REMOTE_REPLICA: - list = ctx->remote.id_list; - tree = ctx->remote.tree; - replica = "REMOTE_REPLICA"; - break; - default: - break; + if (ctx->current != REMOTE_REPLICA) { + return 0; } + list = ctx->remote.id_list; + tree = ctx->remote.tree; + if (list == NULL) { return 0; } @@ -1163,7 +1145,6 @@ static int _csync_correct_id(CSYNC *ctx) { int len; c_rbnode_t *node = NULL; - char pathbuf[PATH_MAX] = {'\0' }; char *old_path = path; csync_file_stat_t *tfs = NULL; @@ -1172,7 +1153,7 @@ static int _csync_correct_id(CSYNC *ctx) { if( seen_dirs && c_list_find_custom( seen_dirs, path, _cmp_char)) { // CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "saw this dir already: %s", path); } else { - CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "climb on dir: %s (%s)", path, replica); + CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "climb on dir: %s", path); seen_dirs = c_list_prepend( seen_dirs, c_strdup(path)); /* Find the correct target entry. */ @@ -1200,11 +1181,8 @@ static int _csync_correct_id(CSYNC *ctx) { } } } - /* get the parent dir */ - /* copy one byte less, omit the trailing slash */ - strncpy( pathbuf, path, strlen(path)-1 ); - /* and get the path name */ - path = c_dirname( pathbuf ); + /* get the parent dir */ + path = c_dirname( path ); /* free the old path memory */ SAFE_FREE(old_path );