Skip to content

Commit

Permalink
Merge branch 'mr/cardao/fix-windows-dir-symlink' into 'master'
Browse files Browse the repository at this point in the history
Fix windows directory symlink

See merge request it/e3-core!2
  • Loading branch information
leocardao committed Jul 16, 2024
2 parents 74a16d8 + fb4cd97 commit e0734ef
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/e3/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ def copystat(src: FileInfo, dst: FileInfo) -> None:

logger.debug("chflags: operation not supported [EOPNOTSUPP]")

def safe_copy(src: FileInfo, dst: FileInfo) -> None:
def safe_copy(src: FileInfo, dst: FileInfo, is_directory: bool = False) -> None:
"""Copy src file into dst preserving all attributes.
:param src: the source FileInfo object
Expand All @@ -809,7 +809,7 @@ def safe_copy(src: FileInfo, dst: FileInfo) -> None:
if not islink(dst) or os.readlink(dst.path) != linkto:
if dst.stat is not None:
rm(dst.path, recursive=True, glob=False)
os.symlink(linkto, dst.path)
os.symlink(linkto, dst.path, target_is_directory=is_directory)
copystat(src, dst)
else:
if isdir(dst):
Expand Down Expand Up @@ -1001,7 +1001,9 @@ def walk(
# the source tree.
if need_update(wf.source, wf.target):
if isfile(wf.source) or islink(wf.source):
safe_copy(wf.source, wf.target)
safe_copy(
wf.source, wf.target, is_directory=os.path.isdir(wf.source.path)
)
updated_list.append(wf.target.path)
elif isdir(wf.source):
safe_mkdir(wf.source, wf.target)
Expand Down

0 comments on commit e0734ef

Please sign in to comment.