From 972412e43642c8d99a65acc40d0358c180ace552 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Fri, 17 Aug 2012 16:48:15 +0300 Subject: [PATCH] Update the md5 sum of files in merge. --- src/csync_util.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/csync_util.c b/src/csync_util.c index e38305b54..4f3af2a02 100644 --- a/src/csync_util.c +++ b/src/csync_util.c @@ -113,12 +113,12 @@ void csync_memstat_check(void) { static int _merge_file_trees_visitor(void *obj, void *data) { csync_file_stat_t *fs = NULL; + csync_file_stat_t *tfs = NULL; csync_vio_file_stat_t *vst = NULL; CSYNC *ctx = NULL; c_rbtree_t *tree = NULL; c_rbnode_t *node = NULL; - char *md5 = NULL; char errbuf[256] = {0}; char *uri = NULL; @@ -179,9 +179,7 @@ static int _merge_file_trees_visitor(void *obj, void *data) { goto out; } } - md5 = fs->md5; fs = c_rbtree_node_data(node); - fs->md5 = md5; switch (ctx->current) { case LOCAL_REPLICA: @@ -221,10 +219,20 @@ static int _merge_file_trees_visitor(void *obj, void *data) { /* update file stat */ fs->inode = vst->inode; fs->modtime = vst->mtime; - // if( vst->md5 ) - // fs->md5 = c_strdup(vst->md5); - CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "file: %s, instruction: UPDATED", uri); + /* update with the id from the remote repo */ + node = c_rbtree_find(ctx->remote.tree, &fs->phash); + if (node == NULL) { + rc = -1; + CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "Unable to find node"); + goto out; + } + + tfs = c_rbtree_node_data(node); + fs->md5 = c_strdup( tfs->md5 ); + CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "PRE UPDATED %s: %s <-> %s", uri, fs->md5, tfs->md5); + + CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "file: %s, instruction: UPDATED (%s)", uri, fs->md5); fs->instruction = CSYNC_INSTRUCTION_NONE;