util: Preserve symlinks when copying
Currently the `copy_all` function resolves all symlinks and crashes on broken symlinks. Instead it should copy symlinks as symlinks. Fixes: https://pagure.io/pungi/issue/1084 Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
8e88373a82
commit
1d020dbedd
2 changed files with 32 additions and 1 deletions
|
|
@ -564,7 +564,11 @@ def copy_all(src, dest):
|
|||
if os.path.isdir(source):
|
||||
shutil.copytree(source, destination)
|
||||
else:
|
||||
shutil.copy2(source, destination)
|
||||
if os.path.islink(source):
|
||||
# It's a symlink, we should preserve it instead of resolving.
|
||||
os.symlink(os.readlink(source), destination)
|
||||
else:
|
||||
shutil.copy2(source, destination)
|
||||
|
||||
return recursive_file_list(src)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue