summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/fprint.c73
-rw-r--r--lib/fprint.h3
-rw-r--r--lib/transaction.c67
3 files changed, 76 insertions, 67 deletions
diff --git a/lib/fprint.c b/lib/fprint.c
index f72a149f8..e6aa42bcd 100644
--- a/lib/fprint.c
+++ b/lib/fprint.c
@@ -5,9 +5,12 @@
#include "system.h"
#include <rpm/rpmfileutil.h> /* for rpmCleanPath */
+#include <rpm/rpmts.h>
+#include <rpm/rpmdb.h>
#include "lib/rpmdb_internal.h"
#include "lib/rpmfi_internal.h"
+#include "lib/rpmte_internal.h"
#include "lib/fprint.h"
#include "lib/misc.h"
#include "debug.h"
@@ -40,8 +43,6 @@ fingerPrintCache fpCacheCreate(int sizeHint)
fpc->ht = rpmFpEntryHashCreate(sizeHint, rstrhash, strcmp,
(rpmFpEntryHashFreeKey)free,
(rpmFpEntryHashFreeData)free);
- fpc->fp = rpmFpHashCreate(sizeHint, fpHashFunction, fpEqual,
- NULL, NULL);
return fpc;
}
@@ -368,3 +369,71 @@ int fpCacheGetByFp(fingerPrintCache cache, struct fingerPrint_s * fp,
{
return rpmFpHashGetEntry(cache->fp, fp, recs, numRecs, NULL);
}
+
+void fpCachePopulate(fingerPrintCache fpc, rpmts ts, int fileCount)
+{
+ rpmtsi pi;
+ rpmte p;
+ rpmfs fs;
+ rpmfi fi;
+ int i, fc;
+
+ if (fpc->fp == NULL)
+ fpc->fp = rpmFpHashCreate(fileCount/2 + 10001, fpHashFunction, fpEqual,
+ NULL, NULL);
+
+ rpmFpHash symlinks = rpmFpHashCreate(fileCount/16+16, fpHashFunction, fpEqual, NULL, NULL);
+
+ pi = rpmtsiInit(ts);
+ while ((p = rpmtsiNext(pi, 0)) != NULL) {
+ (void) rpmdbCheckSignals();
+
+ if ((fi = rpmteFI(p)) == NULL)
+ continue; /* XXX can't happen */
+
+ (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
+ rpmfiFpLookup(fi, fpc);
+ fs = rpmteGetFileStates(p);
+ fc = rpmfsFC(fs);
+ /* collect symbolic links */
+ for (i = 0; i < fc; i++) {
+ struct rpmffi_s ffi;
+ char const *linktarget;
+ if (XFA_SKIPPING(rpmfsGetAction(fs, i)))
+ continue;
+ linktarget = rpmfiFLinkIndex(fi, i);
+ if (!(linktarget && *linktarget != '\0'))
+ continue;
+ ffi.p = p;
+ ffi.fileno = i;
+ rpmFpHashAddEntry(symlinks, rpmfiFpsIndex(fi, i), ffi);
+ }
+ (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), fc);
+
+ }
+ rpmtsiFree(pi);
+
+ /* ===============================================
+ * Check fingerprints if they contain symlinks
+ * and add them to the hash table
+ */
+
+ pi = rpmtsiInit(ts);
+ while ((p = rpmtsiNext(pi, 0)) != NULL) {
+ (void) rpmdbCheckSignals();
+
+ fs = rpmteGetFileStates(p);
+ fc = rpmfsFC(fs);
+ (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
+ for (i = 0; i < fc; i++) {
+ if (XFA_SKIPPING(rpmfsGetAction(fs, i)))
+ continue;
+ fpLookupSubdir(symlinks, fpc, p, i);
+ }
+ (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
+ }
+ rpmtsiFree(pi);
+
+ rpmFpHashFree(symlinks);
+}
+
diff --git a/lib/fprint.h b/lib/fprint.h
index a52349bbd..1a1c8e208 100644
--- a/lib/fprint.h
+++ b/lib/fprint.h
@@ -101,6 +101,9 @@ RPM_GNUC_INTERNAL
int fpCacheGetByFp(fingerPrintCache cache, struct fingerPrint_s * fp,
struct rpmffi_s ** recs, int * numRecs);
+RPM_GNUC_INTERNAL
+void fpCachePopulate(fingerPrintCache cache, rpmts ts, int fileCount);
+
/**
* Return finger print of a file path.
* @param cache pointer to fingerprint cache
diff --git a/lib/transaction.c b/lib/transaction.c
index ca1c1af6a..a8b960641 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -1232,70 +1232,6 @@ static int rpmtsSetupCollections(rpmts ts)
return 0;
}
-/* Add fingerprint for each file not skipped. */
-static void addFingerprints(rpmts ts, uint64_t fileCount, fingerPrintCache fpc)
-{
- rpmtsi pi;
- rpmte p;
- rpmfs fs;
- rpmfi fi;
- int i, fc;
-
- rpmFpHash symlinks = rpmFpHashCreate(fileCount/16+16, fpHashFunction, fpEqual, NULL, NULL);
-
- pi = rpmtsiInit(ts);
- while ((p = rpmtsiNext(pi, 0)) != NULL) {
- (void) rpmdbCheckSignals();
-
- if ((fi = rpmteFI(p)) == NULL)
- continue; /* XXX can't happen */
-
- (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
- rpmfiFpLookup(fi, fpc);
- fs = rpmteGetFileStates(p);
- fc = rpmfsFC(fs);
- /* collect symbolic links */
- for (i = 0; i < fc; i++) {
- struct rpmffi_s ffi;
- char const *linktarget;
- if (XFA_SKIPPING(rpmfsGetAction(fs, i)))
- continue;
- linktarget = rpmfiFLinkIndex(fi, i);
- if (!(linktarget && *linktarget != '\0'))
- continue;
- ffi.p = p;
- ffi.fileno = i;
- rpmFpHashAddEntry(symlinks, rpmfiFpsIndex(fi, i), ffi);
- }
- (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), fc);
-
- }
- rpmtsiFree(pi);
-
- /* ===============================================
- * Check fingerprints if they contain symlinks
- * and add them to the hash table
- */
-
- pi = rpmtsiInit(ts);
- while ((p = rpmtsiNext(pi, 0)) != NULL) {
- (void) rpmdbCheckSignals();
-
- fs = rpmteGetFileStates(p);
- fc = rpmfsFC(fs);
- (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
- for (i = 0; i < fc; i++) {
- if (XFA_SKIPPING(rpmfsGetAction(fs, i)))
- continue;
- fpLookupSubdir(symlinks, fpc, p, i);
- }
- (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
- }
- rpmtsiFree(pi);
-
- rpmFpHashFree(symlinks);
-}
-
static int rpmtsSetup(rpmts ts, rpmprobFilterFlags ignoreSet)
{
rpm_tid_t tid = (rpm_tid_t) time(NULL);
@@ -1387,7 +1323,8 @@ static int rpmtsPrepare(rpmts ts)
}
rpmtsNotify(ts, NULL, RPMCALLBACK_TRANS_START, 6, tsmem->orderCount);
- addFingerprints(ts, fileCount, fpc);
+ /* Add fingerprint for each file not skipped. */
+ fpCachePopulate(fpc, ts, fileCount);
/* check against files in the rpmdb */
checkInstalledFiles(ts, fileCount, fpc);