Further tweak the config file removal/backup logic to make it clearer
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 12 Apr 2012 14:27:24 +0000 (17:27 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 12 Apr 2012 14:27:24 +0000 (17:27 +0300)
- Turn the strange negated condition around: when dealing with
  config files test for it directly. This way, all the special
  cases are handled first and normal cases fall through the if-jungle
  to exactly one case of rpmfsSetAction(fs, i, FA_ERASE). Makes
  the logic more obvious, at least to me.

lib/transaction.c

index 86b2d13..4e89651 100644 (file)
@@ -527,13 +527,10 @@ assert(otherFi != NULL);
                break;
            if (rpmfiFState(fi) != RPMFILE_STATE_NORMAL)
                break;
-           if (!(S_ISREG(FMode) && (FFlags & RPMFILE_CONFIG))) {
-               rpmfsSetAction(fs, i, FA_ERASE);
-               break;
-           }
                
-           /* Here is a pre-existing modified config file that needs saving. */
-           {   int algo = 0;
+           /* Pre-existing modified config files need to be saved. */
+           if (S_ISREG(FMode) && (FFlags & RPMFILE_CONFIG)) {
+               int algo = 0;
                size_t diglen = 0;
                const unsigned char *digest;
                if ((digest = rpmfiFDigest(fi, &algo, &diglen))) {
@@ -547,6 +544,8 @@ assert(otherFi != NULL);
                    }
                }
            }
+       
+           /* Otherwise, we can just erase. */
            rpmfsSetAction(fs, i, FA_ERASE);
            break;
        }