classification
Title: distutils.dir_util.copy_tree FileExistsError when updating symlinks
Type: Stage:
Components: Versions:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Tom Hale
Priority: normal Keywords:

Created on 2020-06-27 03:26 by Tom Hale, last changed 2020-06-27 03:26 by Tom Hale.

Messages (1)
msg372449 - (view) Author: Tom Hale (Tom Hale) * Date: 2020-06-27 03:26
Here is a minimal test case:

==========================================================
#!/bin/bash

cd /tmp || exit 1

dir=test-copy_tree
src=$dir/src
dst=$dir/dst

mkdir -p "$src"
touch "$src"/file
ln -s file "$src/symlink"

python -c "from distutils.dir_util import copy_tree;
copy_tree('$src', '$dst', preserve_symlinks=1, update=1);
copy_tree('$src', '$dst', preserve_symlinks=1, update=1);"

rm -r "$dir"

==========================================================

Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "/usr/lib/python3.8/distutils/dir_util.py", line 152, in copy_tree
    os.symlink(link_dest, dst_name)
FileExistsError: [Errno 17] File exists: 'file' -> 'test-copy_tree/dst/symlink'

==========================================================


Related:
=========

This issue will likely be resolved via:

bpo-36656 Add race-free os.link and os.symlink wrapper / helper

https://bugs.python.org/issue36656
(WIP under discussion at python-mentor)


Prior art:
===========
https://stackoverflow.com/questions/53090360/python-distutils-copy-tree-fails-to-update-if-there-are-symlinks
History
Date User Action Args
2020-06-27 03:26:02Tom Halecreate