From: Zac Medico Date: Thu, 31 May 2007 07:15:18 +0000 (-0000) Subject: Allow dbapi.aux_update() to prune empty metadata values from storage. X-Git-Tag: v2.2_pre1~1327 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0a5d2bcbc71998e595969f836d611a57e8061b37;p=portage.git Allow dbapi.aux_update() to prune empty metadata values from storage. svn path=/main/trunk/; revision=6689 --- diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index b8a24e515..94704e455 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -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): diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 23676c91b..165e04f1e 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -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)