Atomic write

This commit is contained in:
Daniel Mensinger 2018-12-31 14:27:20 +01:00
parent df1434d5a5
commit 25618c6a4d
No known key found for this signature in database
GPG Key ID: 54DD94C131E277D4
1 changed files with 4 additions and 1 deletions

View File

@ -532,8 +532,11 @@ def run(options):
def write_intro_info(intro_info, info_dir):
for i in intro_info:
out_file = os.path.join(info_dir, 'intro-{}.json'.format(i[0]))
with open(out_file, 'w') as fp:
tmp_file = os.path.join(info_dir, 'tmp_dump.json')
with open(tmp_file, 'w') as fp:
json.dump(i[1], fp)
fp.flush() # Not sure if this is needed
os.replace(tmp_file, out_file)
def generate_introspection_file(builddata: build.Build, backend: backends.Backend):
coredata = builddata.environment.get_coredata()