From 79f8122f41116659e944feb6675725d09663a0dd Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Tue, 21 Aug 2012 14:52:06 +0300 Subject: Polish the symlink config file comparison a bit - Similar treatment as in commit 9f9ed70e2d85b0e8f5e2d9cf9969046034d9ad31, pay more attention to what kind of files we're comparing in each case, add a little breathing room and extra comments. - Handle the case where on-disk link is identical to the one in new package in which case no backup will be needed, fixing two cases of unwanted backups in the test-suite. (similar to commit 7a50e9de80ab3c47618dad1e9a5b2d9b79bfc8dc) - Other than the on-disk vs new package change, probably doesn't change anything yet, but prepares us for the next steps. --- lib/rpmfi.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lib/rpmfi.c') diff --git a/lib/rpmfi.c b/lib/rpmfi.c index b069cdd3c..ea1769650 100644 --- a/lib/rpmfi.c +++ b/lib/rpmfi.c @@ -664,8 +664,10 @@ rpmFileAction rpmfiDecideFateIndex(rpmfi ofi, int oix, rpmfi nfi, int nix, } /* ...but otherwise a backup will be needed */ - } else /* dbWhat == LINK */ { + } else if (dbWhat == LINK) { const char * oFLink, * nFLink; + + /* See if the link on disk is identical to the one in old pkg */ oFLink = rpmfiFLinkIndex(ofi, oix); if (diskWhat == LINK) { ssize_t link_len = readlink(fn, buffer, sizeof(buffer) - 1); @@ -675,9 +677,19 @@ rpmFileAction rpmfiDecideFateIndex(rpmfi ofi, int oix, rpmfi nfi, int nix, if (oFLink && rstreq(oFLink, buffer)) return FA_CREATE; /* unmodified config file, replace. */ } + + /* See if the link on disk is identical to the one in new pkg */ nFLink = rpmfiFLinkIndex(nfi, nix); - if (oFLink && nFLink && rstreq(oFLink, nFLink)) + if (diskWhat == LINK && newWhat == LINK) { + if (nFLink && rstreq(nFLink, buffer)) + return FA_CREATE; /* unmodified config file, replace. */ + } + + /* If link is identical in old and new pkg, let it be */ + if (newWhat == LINK && oFLink && nFLink && rstreq(oFLink, nFLink)) return FA_SKIP; /* identical file, don't bother. */ + + /* ...but otherwise a backup will be needed */ } /* -- cgit v1.2.3