summaryrefslogtreecommitdiffstats
path: root/src/makepatch.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2003-09-04 00:19:49 +0000
committerLennart Poettering <lennart@poettering.net>2003-09-04 00:19:49 +0000
commitdbcca8fecac7a6c4f04457b1dbb5682a5fadce58 (patch)
tree1b660d83bc44ded00c5842c17af558d558299bc7 /src/makepatch.c
parent84044171f5aa29fbce94b5ed85345cd50a8ddf56 (diff)
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
Diffstat (limited to 'src/makepatch.c')
-rw-r--r--src/makepatch.c24
1 files changed, 20 insertions, 4 deletions
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;
}