d06308c
commit 7d88d5e54a9c3fa2b7fb443921c8adb799051784
d06308c
Author: Panu Matilainen <pmatilai@redhat.com>
d06308c
Date:   Wed Feb 1 17:48:20 2012 +0200
d06308c
d06308c
    Don't free up file info sets on transaction test-runs
d06308c
    
d06308c
    - We'd like to get rid of the potentially huge amounts of memory
d06308c
      eaten by file info sets as early as possible, but when there's a
d06308c
      chance that we'll get called again with either added transacation
d06308c
      elements or on-disk changes, such as %pretrans changing something
d06308c
      underneath us, we need to (be able to) recalculate everything
d06308c
      from scratch. Only free up the memory when we know we dont need
d06308c
      it anymore, ie on an actual transaction run.
d06308c
    - This doesn't change anything for rpm itself, for yum and others
d06308c
      which do a separate test-transaction first, it means %pretrans
d06308c
      directory<->symlink replacement hacks and the like have a chance
d06308c
      of working again. I'm sure there's a bug filed on this somewhere but...
d06308c
    (cherry picked from commit cef18c94807af0935b7796c462aab8ed39f0f376)
d06308c
d06308c
diff --git a/lib/transaction.c b/lib/transaction.c
d06308c
index 56ebc17..8d29ab9 100644
d06308c
--- a/lib/transaction.c
d06308c
+++ b/lib/transaction.c
d06308c
@@ -1355,12 +1355,14 @@ static int rpmtsPrepare(rpmts ts)
d06308c
     if (rpmChrootOut())
d06308c
 	rc = -1;
d06308c
 
d06308c
-    /* File info sets, fp caches etc not needed beyond here, free 'em up. */
d06308c
-    pi = rpmtsiInit(ts);
d06308c
-    while ((p = rpmtsiNext(pi, 0)) != NULL) {
d06308c
-	rpmteSetFI(p, NULL);
d06308c
+    /* On actual transaction, file info sets are not needed after this */
d06308c
+    if (!(rpmtsFlags(ts) & (RPMTRANS_FLAG_TEST|RPMTRANS_FLAG_BUILD_PROBS))) {
d06308c
+	pi = rpmtsiInit(ts);
d06308c
+	while ((p = rpmtsiNext(pi, 0)) != NULL) {
d06308c
+	    rpmteSetFI(p, NULL);
d06308c
+	}
d06308c
+	rpmtsiFree(pi);
d06308c
     }
d06308c
-    pi = rpmtsiFree(pi);
d06308c
 
d06308c
 exit:
d06308c
     ht = rpmFpHashFree(ht);