mirror of
https://github.com/ValveSoftware/Proton.git
synced 2025-04-08 18:40:14 +03:00
proton: Add write permissions to copied files
We copy some read-only files into the prefix, which can cause problems (specifically, downgrading to some earlier Proton versions).
This commit is contained in:
parent
b1b12f8c4f
commit
746cab7813
15
proton
15
proton
@ -10,6 +10,7 @@ import json
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import errno
|
import errno
|
||||||
|
import stat
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tarfile
|
import tarfile
|
||||||
@ -54,15 +55,23 @@ def makedirs(path):
|
|||||||
#already exists
|
#already exists
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def try_copy(src, dst):
|
def try_copy(src, dst, add_write_perm=True):
|
||||||
try:
|
try:
|
||||||
if os.path.isdir(dst):
|
if os.path.isdir(dst):
|
||||||
dstfile = dst + "/" + os.path.basename(src)
|
dstfile = dst + "/" + os.path.basename(src)
|
||||||
if os.path.lexists(dstfile):
|
if os.path.lexists(dstfile):
|
||||||
os.remove(dstfile)
|
os.remove(dstfile)
|
||||||
elif os.path.lexists(dst):
|
else:
|
||||||
os.remove(dst)
|
dstfile = dst
|
||||||
|
if os.path.lexists(dst):
|
||||||
|
os.remove(dst)
|
||||||
|
|
||||||
shutil.copy(src, dst)
|
shutil.copy(src, dst)
|
||||||
|
|
||||||
|
if add_write_perm:
|
||||||
|
new_mode = os.lstat(dstfile).st_mode | stat.S_IWUSR | stat.S_IWGRP
|
||||||
|
os.chmod(dstfile, new_mode)
|
||||||
|
|
||||||
except PermissionError as e:
|
except PermissionError as e:
|
||||||
if e.errno == errno.EPERM:
|
if e.errno == errno.EPERM:
|
||||||
#be forgiving about permissions errors; if it's a real problem, things will explode later anyway
|
#be forgiving about permissions errors; if it's a real problem, things will explode later anyway
|
||||||
|
Loading…
x
Reference in New Issue
Block a user