From 38a5c97d0b6cee5fb4c658ef4ec1843ec9bb2d0a Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Tue, 12 Jul 2016 11:37:22 +0300 Subject: skeleton: don't truncate index.html on write error Write new version to a temporary file and rename it to index.html. --- tools/skeleton.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/skeleton.py b/tools/skeleton.py index 548bd40..e7857a3 100755 --- a/tools/skeleton.py +++ b/tools/skeleton.py @@ -170,8 +170,10 @@ def update_index_html(name, description, website): packages_html += '\n' # build and write HTML index_html = prefix + sep1 + packages_html + sep2 + suffix - with open('index.html', 'wt') as f: + (_, tmp_index_html) = tempfile.mkstemp() + with open(tmp_index_html, 'wt') as f: f.write(index_html) + os.rename(tmp_index_html, 'index.html') def make_skeleton( name, -- cgit v0.12