Skip to content

Commit c55cf5a

Browse files
author
José Valim
committed
Do not traverse filesystem on empty paths
See #5551 Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
1 parent d28cc75 commit c55cf5a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/logger/test/logger/utils_test.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,8 @@ defmodule Logger.UtilsTest do
100100
time = {12, 30, 10, 10}
101101
assert format_time(time) == ["12", ?:, "30", ?:, "10", ?., [?0, "10"]]
102102
end
103+
104+
test "extract_files/2 with empty string returns empty list" do
105+
assert extract_files([""], ".ex") == []
106+
end
103107
end

lib/mix/lib/mix/utils.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ defmodule Mix.Utils do
138138

139139
def extract_files(paths, pattern) do
140140
Enum.flat_map(paths, fn path ->
141-
if File.regular?(path), do: [path], else: Path.wildcard("#{path}/**/#{pattern}")
141+
case :elixir_utils.read_file_type(path) do
142+
{:ok, :directory} -> Path.wildcard("#{path}/**/#{pattern}")
143+
{:ok, :regular} -> [path]
144+
_ -> []
145+
end
142146
end) |> Enum.uniq
143147
end
144148

0 commit comments

Comments
 (0)