summaryrefslogtreecommitdiff
path: root/backport-Consolidate-skipped-hardlink-with-content-case-with-.patch
blob: e992dca3b4d2bc9e894967ff1134948ff1043d2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From cc22fc694d30a64862f0b16d137deaab5416382d Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Fri, 11 Feb 2022 13:05:45 +0200
Subject: [PATCH] Consolidate skipped hardlink with content case with the
 others

Handling this in a separate clause makes the logic much clearer and
(in theory at least) lets us handle hardlinks to any content, not
just regular files.
---
 lib/fsm.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/fsm.c b/lib/fsm.c
index ec6ee2c..82610c7 100644
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -832,9 +832,18 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
     while (!rc && (fx = rpmfiNext(fi)) >= 0) {
 	struct filedata_s *fp = &fdata[fx];
 
+	/*
+	 * Tricksy case: this file is a being skipped, but it's part of
+	 * a hardlinked set and has the actual content linked with it.
+	 * Write the content to the first non-skipped file of the set
+	 * instead.
+	 */
+	if (fp->skip && firstlink && rpmfiArchiveHasContent(fi))
+	    fp = firstlink;
+
         if (!fp->skip) {
 	    /* Directories replacing something need early backup */
-	    if (!fp->suffix) {
+	    if (!fp->suffix && fp != firstlink) {
 		rc = fsmBackup(fi, fp->action);
 	    }
 
@@ -904,15 +913,6 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
                 if (!IS_DEV_LOG(fp->fpath))
                     rc = RPMERR_UNKNOWN_FILETYPE;
             }
-	} else if (firstlink && rpmfiArchiveHasContent(fi)) {
-	    /*
-	     * Tricksy case: this file is a being skipped, but it's part of
-	     * a hardlinked set and has the actual content linked with it.
-	     * Write the content to the first non-skipped file of the set
-	     * instead.
-	     */
-	    rc = fsmMkfile(fi, firstlink, files, psm, nodigest,
-			   &firstlink, &firstlinkfile);
 	}
 
 	/* Notify on success. */
-- 
1.8.3.1