Commit 837c540d authored by Julien Muchembled's avatar Julien Muchembled

Revert "Save installed database in an atomic way"

This reverts commit 54bbe6bf.
parent 4f679e8d
......@@ -839,16 +839,11 @@ class Buildout(UserDict.DictMixin):
def _update_installed(self, **buildout_options):
installed = self['buildout']['installed']
# read old installed database
with open(installed, 'r') as f:
installed_data = f.read()
installed_data = '%s\n[buildout]\n' % installed_data
f = StringIO()
f.write(installed_data)
f = open(installed, 'a')
f.write('\n[buildout]\n')
for option, value in buildout_options.items():
_save_option(option, value, f)
self._save_installed_database(f.getvalue())
f.close()
def _uninstall_part(self, part, installed_part_options):
# uninstall part
......@@ -1012,33 +1007,17 @@ class Buildout(UserDict.DictMixin):
for d in installed]
return ' '.join(installed)
def _save_installed_database(self, text):
# Saved installed database in an atomic fashion
installed = self['buildout']['installed']
temp_installed = '%s.tmp' % installed
try:
with open(temp_installed, 'w') as f:
f.write(text)
f.flush()
os.fsync(f.fileno())
os.rename(temp_installed, installed)
finally:
try:
os.remove(temp_installed)
except OSError:
pass
def _save_installed_options(self, installed_options):
installed = self['buildout']['installed']
if not installed:
return
f = StringIO()
f = open(installed, 'w')
_save_options('buildout', installed_options['buildout'], f)
for part in installed_options['buildout']['parts'].split():
print >>f
_save_options(part, installed_options[part], f)
self._save_installed_database(f.getvalue())
f.close()
def _error(self, message, *args):
raise zc.buildout.UserError(message % args)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment