Commit 9e142f8c authored by Holger Levsen's avatar Holger Levsen

reproducible: write json to tempfile first, so that updates are atomic

parent b7a30381
......@@ -12,6 +12,9 @@
from reproducible_common import *
import json
import os
import tempfile
output = []
......@@ -29,8 +32,12 @@ for row in result:
log.debug(pkg)
output.append(pkg)
with open(REPRODUCIBLE_JSON, 'w') as fd:
tmpfile = tempfile.NamedTemporaryFile(dir=os.path.dirname(REPRODUCIBLE_JSON))
with open(tmpfile.name, 'w') as fd:
json.dump(output, fd, indent=4, sort_keys=True)
os.rename(tmpfile.name, REPRODUCIBLE_JSON)
log.info(REPRODUCIBLE_URL + '/reproducible.json has been updated.')
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