diff options
author | RĂ©mi Bernon <rbernon@codeweavers.com> | 2021-12-16 13:34:07 +0300 |
---|---|---|
committer | Arkadiusz Hiler <ahiler@codeweavers.com> | 2022-01-19 12:29:54 +0300 |
commit | 16b662a0bfd0613e37ee71876d4518af5e7b64bb (patch) | |
tree | 6889b4f35add1f484c6526aa95671a42c146fb0d /proton | |
parent | 212cbc0c9aa00dfa201b3ab1c28009096186448d (diff) |
proton: Always set dst to the target file name in try_copy.
Diffstat (limited to 'proton')
-rwxr-xr-x | proton | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -112,13 +112,10 @@ def merge_user_dir(src, dst): def try_copy(src, dst, add_write_perm=True, copy_metadata=False, optional=False, follow_symlinks=True): try: if os.path.isdir(dst): - dstfile = dst + "/" + os.path.basename(src) - if os.path.lexists(dstfile): - os.remove(dstfile) - else: - dstfile = dst - if os.path.lexists(dst): - os.remove(dst) + dst = os.path.join(dst, os.path.basename(src)) + + if os.path.lexists(dst): + os.remove(dst) if copy_metadata: shutil.copy2(src, dst, follow_symlinks=follow_symlinks) @@ -126,8 +123,8 @@ def try_copy(src, dst, add_write_perm=True, copy_metadata=False, optional=False, shutil.copy(src, dst, follow_symlinks=follow_symlinks) if add_write_perm: - new_mode = os.lstat(dstfile).st_mode | stat.S_IWUSR | stat.S_IWGRP - os.chmod(dstfile, new_mode) + new_mode = os.lstat(dst).st_mode | stat.S_IWUSR | stat.S_IWGRP + os.chmod(dst, new_mode) except FileNotFoundError as e: if optional: |