cpdup - Fix bug where cpdup sometimes does not remove files on target
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 25 Mar 2010 17:35:43 +0000 (10:35 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 25 Mar 2010 17:35:43 +0000 (10:35 -0700)
* Fix a bug introduced in a recent commit which caused cpdup to sometimes
  not remove files on the target which were removed from the source.

Submitted-by: Oliver Fromme <check+kzu4p100rs0rfx01@fromme.com>
bin/cpdup/cpdup.c

index f4b3b90..04b9754 100644 (file)
@@ -975,12 +975,13 @@ relink:
 
        if (!skipdir) {
            List *list = malloc(sizeof(List));
-           Node *node = NULL;
+           Node *node;
            char *name;
 
            if (DirShowOpt)
                logstd("Scanning %s ...\n", spath);
            InitList(list);
+           node = NULL;
            if (ScanDir(list, &SrcHost, spath, &CountSourceReadBytes, 0) == 0) {
                while ((name = IterateList(list, &node, 0)) != NULL) {
                    char *nspath;
@@ -1010,7 +1011,8 @@ relink:
                 * in the source.
                 */
                if (dpath && ScanDir(list, &DstHost, dpath,
-                       &CountTargetReadBytes, 3) == 0) {
+                                    &CountTargetReadBytes, 3) == 0) {
+                   node = NULL;
                    while ((name = IterateList(list, &node, 3)) != NULL) {
                        /*
                         * If object does not exist in source or .cpignore