From dbcca8fecac7a6c4f04457b1dbb5682a5fadce58 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 4 Sep 2003 00:19:49 +0000 Subject: added atomicty makepatch omits files existant on other other host under a different name git-svn-id: file:///home/lennart/svn/public/syrep/trunk@21 07ea20a6-d2c5-0310-9e02-9ef735347d72 --- src/makepatch.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/makepatch.c') diff --git a/src/makepatch.c b/src/makepatch.c index 8bf1ee5..6e350f5 100644 --- a/src/makepatch.c +++ b/src/makepatch.c @@ -47,6 +47,8 @@ static int cb(DB *ddb, struct syrep_name *name, struct diff_entry *de, void *p) if (de->action != DIFF_COPY && de->action != DIFF_CONFLICT) return 0; + /* Check whether file exists in c1. If not, exit */ + if ((f = get_nrecno_by_name(cb_info->c1, name, &nrecno, 0)) < 0) return -1; @@ -57,19 +59,33 @@ static int cb(DB *ddb, struct syrep_name *name, struct diff_entry *de, void *p) if (!f) return 0; + /* Omit if the file exists in c2 under a different name */ + + if (!args.include_all_flag) { + + if ((f = get_current_nrecno_by_md(cb_info->c2, &md, NULL)) < 0) + return -1; + + if (f) + return 0; + } + + /* Ok, we add this file to the patch */ + fhex(md.digest, SYREP_DIGESTLENGTH, d); d[SYREP_DIGESTLENGTH*2] = 0; snprintf(path, sizeof(path), "%s/%s", cb_info->root, name->path); - fprintf(stderr, "Adding %s (%s) to patch.\n", name->path, d); + if (!package_get_item(cb_info->c1->package, d, 0)) { - /*** MISSING: DO NOT ADD FILES ALREADY EXISTING BY MD5 ***/ - - if (!package_get_item(cb_info->c1->package, d, 0)) + fprintf(stderr, "Adding %s (%s) to patch.\n", name->path, d); + if (package_add_file(cb_info->c1->package, d, path) < 0) return -1; + } + return 0; } -- cgit