From eab63c6af89d2e7f21a4a2f03b0a2cdfec252dca Mon Sep 17 00:00:00 2001 From: shortcutme Date: Wed, 4 Sep 2019 20:15:37 +0200 Subject: [PATCH] Keep file permissions on update rename workaround --- update.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/update.py b/update.py index 0dfff297..e55eaa57 100644 --- a/update.py +++ b/update.py @@ -2,6 +2,7 @@ import os import sys import json import re +import shutil def update(): @@ -94,13 +95,14 @@ def update(): num_ok += 1 except Exception as err: try: - print("Error writing: %s. Renaming old file to avoid lock on Windows..." % err) + print("Error writing: %s. Renaming old file as workaround..." % err) path_to_tmp = path_to + "-old" if os.path.isfile(path_to_tmp): os.unlink(path_to_tmp) os.rename(path_to, path_to_tmp) num_rename += 1 open(path_to, 'wb').write(data) + shutil.copymode(path_to_tmp, path_to) # Copy permissions print("Write done after rename!") num_ok += 1 except Exception as err: