Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion reflex/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ def asset(
if not dst_file.exists() and (
not dst_file.is_symlink() or dst_file.resolve() != src_file_shared.resolve()
):
dst_file.symlink_to(src_file_shared)
try:
dst_file.symlink_to(src_file_shared)
except FileExistsError:
# This happens when Simon builds the app on a bind mount in a docker container.
dst_file.unlink()
dst_file.symlink_to(src_file_shared)
Comment on lines +97 to +100
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching FileExistsError and blindly unlinking could be risky if a race condition creates a legitimate file between the check on line 92 and the symlink creation. Consider checking dst_file.is_symlink() before unlinking to ensure you're only removing symlinks:

Suggested change
except FileExistsError:
# This happens when Simon builds the app on a bind mount in a docker container.
dst_file.unlink()
dst_file.symlink_to(src_file_shared)
except FileExistsError:
# This happens when Simon builds the app on a bind mount in a docker container.
if dst_file.is_symlink():
dst_file.unlink()
dst_file.symlink_to(src_file_shared)
else:
raise


return f"/{external}/{subfolder}/{path}"
Loading