fix(safety): replace File.read! with File.read and error-tuple handling in preview_assets and templates (CSM-034)

This commit is contained in:
2026-05-27 19:10:13 +02:00
parent e29dfb490a
commit 9e6d93a4b3
4 changed files with 162 additions and 37 deletions

View File

@@ -28,8 +28,11 @@ defmodule BDS.PreviewAssets do
end)
|> Enum.filter(&File.regular?/1)
|> Enum.sort()
|> Enum.map(fn path ->
{Path.relative_to(path, @preview_root), File.read!(path)}
|> Enum.flat_map(fn path ->
case File.read(path) do
{:ok, contents} -> [{Path.relative_to(path, @preview_root), contents}]
{:error, _reason} -> []
end
end)
end