Skip to content

Commit eab63c6

Browse files
committed
Keep file permissions on update rename workaround
1 parent 4f06136 commit eab63c6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

update.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import sys
33
import json
44
import re
5+
import shutil
56

67

78
def update():
@@ -94,13 +95,14 @@ def update():
9495
num_ok += 1
9596
except Exception as err:
9697
try:
97-
print("Error writing: %s. Renaming old file to avoid lock on Windows..." % err)
98+
print("Error writing: %s. Renaming old file as workaround..." % err)
9899
path_to_tmp = path_to + "-old"
99100
if os.path.isfile(path_to_tmp):
100101
os.unlink(path_to_tmp)
101102
os.rename(path_to, path_to_tmp)
102103
num_rename += 1
103104
open(path_to, 'wb').write(data)
105+
shutil.copymode(path_to_tmp, path_to) # Copy permissions
104106
print("Write done after rename!")
105107
num_ok += 1
106108
except Exception as err:

0 commit comments

Comments
 (0)