Skip to content

Commit 53568ca

Browse files
committed
Fix deprecation warning about Enum.partition/2 in Elixir 1.6
and make it work in Elixirs <= 1.4
1 parent 9034582 commit 53568ca

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/temp/tracker.ex

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@ defmodule Temp.Tracker do
3333
end
3434

3535
defp cleanup(state) do
36-
Enum.partition state, fn path ->
37-
case File.rm_rf(path) do
38-
{:ok, _} -> true
39-
_ -> false
40-
end
41-
end
36+
{removed, failed} =
37+
state
38+
|> Enum.reduce({[], []}, fn path, {removed, failed} ->
39+
case File.rm_rf(path) do
40+
{:ok, _} -> {[path | removed], failed}
41+
_ -> {removed, [path | failed]}
42+
end
43+
end)
44+
{:lists.reverse(removed), :lists.reverse(failed)}
4245
end
4346
end

0 commit comments

Comments
 (0)