mirror of
https://github.com/ValveSoftware/Proton.git
synced 2025-01-26 05:28:15 +03:00
proton: Remove files before trying to copy over them
If the file is a symlink, it could dereference the link and overwrite the pointed-to file.
This commit is contained in:
parent
8531ea2c9d
commit
ee4510682f
6
proton
6
proton
@ -130,6 +130,12 @@ def makedirs(path):
|
|||||||
|
|
||||||
def try_copy(src, dst):
|
def try_copy(src, dst):
|
||||||
try:
|
try:
|
||||||
|
if os.path.isdir(dst):
|
||||||
|
dstfile = dst + "/" + os.path.basename(src)
|
||||||
|
if os.path.lexists(dstfile):
|
||||||
|
os.remove(dstfile)
|
||||||
|
elif os.path.lexists(dst):
|
||||||
|
os.remove(dst)
|
||||||
shutil.copy(src, dst)
|
shutil.copy(src, dst)
|
||||||
except PermissionError as e:
|
except PermissionError as e:
|
||||||
if e.errno == errno.EPERM:
|
if e.errno == errno.EPERM:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user