Make bindbapi override cpv_inject and cpv_remove, for deleting stale values
authorZac Medico <zmedico@gentoo.org>
Tue, 2 Mar 2010 21:08:12 +0000 (21:08 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 2 Mar 2010 21:08:12 +0000 (21:08 -0000)
from self._aux_cache. Also, add a comment about stale cache handling inside
aux_update. (trunk r15488)

svn path=/main/branches/2.1.7/; revision=15689

pym/portage/dbapi/bintree.py

index 626e55808e01849d55b6eafceafa9a5eeccae5f7..e4f3e60fca35a34e554d0f86bc31e4f294221445 100644 (file)
@@ -65,6 +65,14 @@ class bindbapi(fakedbapi):
                        self.bintree.populate()
                return fakedbapi.match(self, *pargs, **kwargs)
 
+       def cpv_inject(self, cpv, **kwargs):
+               self._aux_cache.pop(cpv, None)
+               fakedbapi.cpv_inject(cpv, **kwargs)
+
+       def cpv_remove(self, cpv):
+               self._aux_cache.pop(cpv, None)
+               fakedbapi.cpv_remove(cpv)
+
        def aux_get(self, mycpv, wants):
                if self.bintree and not self.bintree.populated:
                        self.bintree.populate()
@@ -135,6 +143,7 @@ class bindbapi(fakedbapi):
                        if not v:
                                del mydata[k]
                mytbz2.recompose_mem(portage.xpak.xpak_mem(mydata))
+               # inject will clear stale caches via cpv_inject.
                self.bintree.inject(cpv)
 
        def cp_list(self, *pargs, **kwargs):
@@ -917,7 +926,6 @@ class binarytree(object):
                        return
                slot = slot.strip()
                self.dbapi.cpv_inject(cpv)
-               self.dbapi._aux_cache.pop(cpv, None)
 
                # Reread the Packages index (in case it's been changed by another
                # process) and then updated it, all while holding a lock.