Manifest.write(): tweak unlink logic
authorZac Medico <zmedico@gentoo.org>
Wed, 28 Sep 2011 06:48:59 +0000 (23:48 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 28 Sep 2011 06:48:59 +0000 (23:48 -0700)
This narrows the range of possible behaviors, such that the manifest
will always be either written or unlinked, eliminating the possiblity
that a stale manifest will ever be allowed to slip through without
being overwritten or unlinked.

pym/portage/manifest.py

index 7cac09cde02763970df4d067992b984f73563c34..49c05bd484a1d60897df5a412999d13df17dbcec 100644 (file)
@@ -267,10 +267,14 @@ class Manifest(object):
                                                raise
 
                        if update_manifest:
-                               if myentries:
+                               if myentries or not (self.thin or self.allow_missing):
+                                       # If myentries is empty, don't write an empty manifest
+                                       # when thin or allow_missing is enabled. Except for
+                                       # thin manifests with no DIST entries, myentries is
+                                       # non-empty for all currently known use cases.
                                        write_atomic(self.getFullname(), "".join("%s\n" %
                                                str(myentry) for myentry in myentries))
-                               elif self.thin:
+                               else:
                                        # With thin manifest, there's no need to have
                                        # a Manifest file if there are no DIST entries.
                                        try: