Allow dbapi.aux_update() to prune empty metadata values from storage.
authorZac Medico <zmedico@gentoo.org>
Thu, 31 May 2007 07:15:18 +0000 (07:15 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 31 May 2007 07:15:18 +0000 (07:15 -0000)
svn path=/main/trunk/; revision=6689

pym/portage/dbapi/bintree.py
pym/portage/dbapi/vartree.py

index b8a24e515b6e1121ebc3f581688a398472743145..94704e45565bb6ddb22aa151d3df6e68c9a0c88a 100644 (file)
@@ -77,6 +77,9 @@ class bindbapi(fakedbapi):
                mytbz2 = portage.xpak.tbz2(tbz2path)
                mydata = mytbz2.get_data()
                mydata.update(values)
+               for k, v in mydata.items():
+                       if not v:
+                               del mydata[k]
                mytbz2.recompose_mem(portage.xpak.xpak_mem(mydata))
 
        def cp_list(self, *pargs, **kwargs):
index 23676c91b7d945688010a3f595bda49959fad26c..165e04f1e7419f26de74aa3c9e1f90fb7a3b51a3 100644 (file)
@@ -551,7 +551,13 @@ class vardbapi(dbapi):
                if not mylink.exists():
                        raise KeyError(cpv)
                for k, v in values.iteritems():
-                       mylink.setfile(k, v)
+                       if v:
+                               mylink.setfile(k, v)
+                       else:
+                               try:
+                                       os.unlink(os.path.join(self.getpath(cpv), k))
+                               except EnvironmentError:
+                                       pass
 
        def counter_tick(self, myroot, mycpv=None):
                return self.counter_tick_core(myroot, incrementing=1, mycpv=mycpv)