Avoid stat call in llnl.util.symlink on non-windows (#34321)

This commit is contained in:
Harmen Stoppels 2022-12-06 16:17:15 +01:00 committed by GitHub
parent b58ec9e2b9
commit e3bf7358d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,7 +23,10 @@ def symlink(real_path, link_path):
On Windows, use junctions if os.symlink fails.
"""
if not is_windows or _win32_can_symlink():
if not is_windows:
os.symlink(real_path, link_path)
elif _win32_can_symlink():
# Windows requires target_is_directory=True when the target is a dir.
os.symlink(real_path, link_path, target_is_directory=os.path.isdir(real_path))
else:
try: