Skip to content

Commit

Permalink
fix(Util): do not raise if File.stat/1 fails
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceEEC committed Jul 10, 2018
1 parent d213d84 commit 5230c0f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/rest/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ defmodule Crux.Rest.Util do
{:error, other}
end

File.exists?(bin_or_path) && File.stat!(bin_or_path).type == :regular ->
map_file({:file, bin_or_path, Path.basename(name)})
File.exists?(bin_or_path) ->
with {:ok, %{type: :regular}} <- File.stat(bin_or_path) do
map_file({:file, bin_or_path, Path.basename(name)})
end

true ->
map_file({Path.basename(name), bin_or_path, Path.basename(name)})
Expand Down

0 comments on commit 5230c0f

Please sign in to comment.