Skip to content

Commit 462b4e0

Browse files
authored
fix: Keep symlinks when copying files after build (#7890)
1 parent 42ba2f7 commit 462b4e0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

samcli/lib/utils/osutils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def copytree(source, destination, ignore=None):
180180
copytree(new_source, new_destination, ignore=ignore)
181181
else:
182182
try:
183-
shutil.copy2(new_source, new_destination)
183+
shutil.copy2(new_source, new_destination, follow_symlinks=False)
184184
except OSError as e:
185185
if e.errno != errno.EINVAL:
186186
raise e

tests/unit/lib/utils/test_osutils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def test_must_copytree(self, patched_copy2, patched_os, patched_path):
107107
osutils.copytree(source_path, destination_path)
108108

109109
patched_os.path.join.assert_called()
110-
patched_copy2.assert_called_with(source_path, destination_path)
110+
patched_copy2.assert_called_with(source_path, destination_path, follow_symlinks=False)
111111

112112
@patch("samcli.lib.utils.osutils.Path")
113113
@patch("samcli.lib.utils.osutils.os")
@@ -127,7 +127,7 @@ def test_copytree_throws_oserror_path_exists(self, patched_copy2, patched_os, pa
127127
osutils.copytree(source_path, destination_path)
128128

129129
patched_os.path.join.assert_called()
130-
patched_copy2.assert_called_with(source_path, destination_path)
130+
patched_copy2.assert_called_with(source_path, destination_path, follow_symlinks=False)
131131

132132
@patch("samcli.lib.utils.osutils.create_symlink_or_copy")
133133
@patch("samcli.lib.utils.osutils.Path")
@@ -149,7 +149,7 @@ def test_copytree_symlink_copy_error_handling(
149149
osutils.copytree(source_path, destination_path)
150150

151151
patched_os.path.join.assert_called()
152-
patched_copy2.assert_called_with(source_path, destination_path)
152+
patched_copy2.assert_called_with(source_path, destination_path, follow_symlinks=False)
153153
patched_create_symlink_or_copy.assert_called_with(source_path, destination_path)
154154

155155

0 commit comments

Comments
 (0)