mirror of
https://github.com/HelloZeroNet/ZeroNet.git
synced 2023-12-14 04:33:03 +01:00
Keep file permissions on update rename workaround
This commit is contained in:
parent
4f0613689a
commit
eab63c6af8
1 changed files with 3 additions and 1 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue