From 25618c6a4dd8e2c05d0e19ee19f4e6a5e735ef0c Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Mon, 31 Dec 2018 14:27:20 +0100 Subject: Atomic write --- mesonbuild/mintro.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mesonbuild') diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index cba10f3..e6782cb 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -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() -- cgit v1.1