Make PreservedLibsRegistry.store() use atomic_ofstream so that we don't
authorZac Medico <zmedico@gentoo.org>
Tue, 19 Feb 2008 04:09:20 +0000 (04:09 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 19 Feb 2008 04:09:20 +0000 (04:09 -0000)
lose the whole registry if an error such as 'out of space' occurs.

svn path=/main/trunk/; revision=9354

pym/portage/dbapi/vartree.py

index 70397813323fb07ecb9ed98fe2cca67ebda773d9..b85976931008989e868040c54a05b891574449f8 100644 (file)
@@ -63,8 +63,10 @@ class PreservedLibsRegistry(object):
                """ Store the registry data to file. No need to call this if autocommit
                    was enabled.
                """
-               cPickle.dump(self._data, open(self._filename, "w"))
-       
+               f = atomic_ofstream(self._filename)
+               cPickle.dump(self._data, f)
+               f.close()
+
        def register(self, cpv, slot, counter, paths):
                """ Register new objects in the registry. If there is a record with the
                        same packagename (internally derived from cpv) and slot it is