From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1N2uqA-0000gw-Ih for garchives@archives.gentoo.org; Tue, 27 Oct 2009 22:48:34 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 266F1E07CC; Tue, 27 Oct 2009 22:48:34 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id D8ABAE07CC for ; Tue, 27 Oct 2009 22:48:33 +0000 (UTC) Received: from stork.gentoo.org (stork.gentoo.org [64.127.104.133]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTP id 84EA5679CA for ; Tue, 27 Oct 2009 22:48:33 +0000 (UTC) Received: from zmedico by stork.gentoo.org with local (Exim 4.69) (envelope-from ) id 1N2uq8-0003E5-SO for gentoo-commits@lists.gentoo.org; Tue, 27 Oct 2009 22:48:32 +0000 To: gentoo-commits@lists.gentoo.org From: "Zac Medico (zmedico)" Subject: [gentoo-commits] portage r14735 - main/trunk/pym/portage/dbapi X-VCS-Repository: portage X-VCS-Revision: 14735 X-VCS-Files: main/trunk/pym/portage/dbapi/vartree.py X-VCS-Directories: main/trunk/pym/portage/dbapi X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico Content-Type: text/plain; charset=UTF-8 Message-Id: Sender: Zac Medico Date: Tue, 27 Oct 2009 22:48:32 +0000 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 7ca45a35-949f-4e64-b536-bd332cd882a7 X-Archives-Hash: 44401eac1467c53ee9b1de420ba36a4e Author: zmedico Date: 2009-10-27 22:48:32 +0000 (Tue, 27 Oct 2009) New Revision: 14735 Modified: main/trunk/pym/portage/dbapi/vartree.py Log: Bug #290428 - Update mtime of /var/db/pkg and category subdirectories whe= n stuff inside is modified, so that consumers can use directory mtimes to validate caches. Modified: main/trunk/pym/portage/dbapi/vartree.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/trunk/pym/portage/dbapi/vartree.py 2009-10-26 22:26:31 UTC (rev = 14734) +++ main/trunk/pym/portage/dbapi/vartree.py 2009-10-27 22:48:32 UTC (rev = 14735) @@ -52,6 +52,7 @@ import logging import os as _os import sys +import time import warnings =20 try: @@ -849,6 +850,19 @@ rValue =3D _os.path.join(rValue, filename) return rValue =20 + def _bump_mtime(self, cpv): + """ + This is called before an after any modifications, so that consumers + can use directory mtimes to validate caches. See bug #290428. + """ + base =3D self.root + _os.sep + VDB_PATH + cat =3D catsplit(cpv)[0] + catdir =3D base + _os.sep + cat + t =3D time.time() + t =3D (t, t) + for x in (catdir, base): + os.utime(x, t) + def cpv_exists(self, mykey): "Tells us whether an actual ebuild exists on disk (no masking)" return os.path.exists(self.getpath(mykey)) @@ -1301,6 +1315,7 @@ return results =20 def aux_update(self, cpv, values): + self._bump_mtime(cpv) cat, pkg =3D catsplit(cpv) mylink =3D dblink(cat, pkg, self.root, self.settings, treetype=3D"vartree", vartree=3Dself.vartree) @@ -1314,6 +1329,7 @@ os.unlink(os.path.join(self.getpath(cpv), k)) except EnvironmentError: pass + self._bump_mtime(cpv) =20 def counter_tick(self, myroot, mycpv=3DNone): return self.counter_tick_core(myroot, incrementing=3D1, mycpv=3Dmycpv) @@ -1435,9 +1451,11 @@ removed +=3D 1 =20 if removed: + self._bump_mtime(pkg.mycpv) f =3D atomic_ofstream(os.path.join(pkg.dbdir, "CONTENTS")) write_contents(new_contents, root, f) f.close() + self._bump_mtime(pkg.mycpv) pkg._clear_contents_cache() =20 class _owners_cache(object): @@ -2067,6 +2085,7 @@ The caller must ensure that lockdb() and unlockdb() are called before and after this method. """ + self.vartree.dbapi._bump_mtime(self.mycpv) showMessage =3D self._display_merge if self.vartree.dbapi._categories is not None: self.vartree.dbapi._categories =3D None @@ -2208,6 +2227,7 @@ self.vartree.dbapi.plib_registry.pruneNonExisting() =20 finally: + self.vartree.dbapi._bump_mtime(self.mycpv) if builddir_lock: try: if myebuildpath: @@ -4341,6 +4361,7 @@ mydbapi=3DNone, prev_mtimes=3DNone): retval =3D -1 self.lockdb() + self.vartree.dbapi._bump_mtime(self.mycpv) try: self.vartree.dbapi.plib_registry.load() self.vartree.dbapi.plib_registry.pruneNonExisting() @@ -4366,6 +4387,7 @@ finally: self.vartree.dbapi.linkmap._clear_cache() self.unlockdb() + self.vartree.dbapi._bump_mtime(self.mycpv) return retval =20 def getstring(self,name):