From 7a216218968dc1d00f2881121870611bc1b5dd33 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 14 Sep 2011 19:36:54 -0700 Subject: Remove Manifest if it is not needed. With thin manifest, there's no need to have a Manifest file if there are no DIST entries. --- pym/portage/manifest.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py index 32cc2c025..449f9fdf4 100644 --- a/pym/portage/manifest.py +++ b/pym/portage/manifest.py @@ -241,7 +241,7 @@ class Manifest(object): try: myentries = list(self._createManifestEntries()) update_manifest = True - if not force: + if myentries and not force: try: f = io.open(_unicode_encode(self.getFullname(), encoding=_encodings['fs'], errors='strict'), @@ -257,15 +257,23 @@ class Manifest(object): break except (IOError, OSError) as e: if e.errno == errno.ENOENT: - if not myentries: - # With thin manifest, there's no need to have - # a Manifest file if there are no DIST entries. - update_manifest = False + pass else: raise + if update_manifest: - write_atomic(self.getFullname(), - "".join("%s\n" % str(myentry) for myentry in myentries)) + if myentries: + write_atomic(self.getFullname(), "".join("%s\n" % + str(myentry) for myentry in myentries)) + else: + # With thin manifest, there's no need to have + # a Manifest file if there are no DIST entries. + try: + os.unlink(self.getFullname()) + except OSError as e: + if e.errno != errno.ENOENT: + raise + if sign: self.sign() except (IOError, OSError) as e: -- cgit v1.2.3-1-g7c22