Skip to content

Commit 86a8a6e

Browse files
author
José Valim
committed
Tidy up previous commits
1 parent 4d5696e commit 86a8a6e

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

lib/elixir/lib/file.ex

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,9 @@ defmodule File do
743743

744744
@doc """
745745
Tries to delete the file `path`.
746+
746747
Returns `:ok` if successful, or `{:error, reason}` if an error occurs.
748+
Note the file is deleted even if in read-only mode.
747749
748750
Typical error reasons are:
749751
@@ -765,16 +767,27 @@ defmodule File do
765767
"""
766768
@spec rm(Path.t) :: :ok | {:error, posix}
767769
def rm(path) do
770+
path = IO.chardata_to_string(path)
771+
case F.delete(path) do
772+
:ok ->
773+
:ok
774+
{:error, :eaccess} = e ->
775+
change_mode_windows(path) || e
776+
{:error, _} = e ->
777+
e
778+
end
779+
end
780+
781+
defp change_mode_windows(path) do
768782
if match? {:win32, _}, :os.type do
769783
case F.read_file_info(IO.chardata_to_string(path)) do
770-
{:ok, file_info} ->
771-
if elem(file_info, 3) in [:read, :none] do
772-
File.chmod(path, (elem(file_info, 7) + 0200))
773-
end
774-
{:error, reason} -> {:error, reason}
784+
{:ok, file_info} when elem(file_info, 3) in [:read, :none] ->
785+
File.chmod(path, (elem(file_info, 7) + 0200))
786+
F.delete(path)
787+
_ ->
788+
nil
775789
end
776790
end
777-
F.delete(IO.chardata_to_string(path))
778791
end
779792

780793
@doc """

lib/iex/lib/iex/server.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ defmodule IEx.Server do
128128

129129
defp exit_loop(evaluator, evaluator_ref, done? \\ true) do
130130
Process.delete(:evaluator)
131-
Process.demonitor(evaluator_ref)
131+
Process.demonitor(evaluator_ref, [:flush])
132132
if done? do
133133
send(evaluator, {:done, self})
134134
end

lib/mix/lib/mix/utils.ex

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,10 @@ defmodule Mix.Utils do
405405
if http_proxy = System.get_env("HTTP_PROXY"), do: proxy(http_proxy)
406406
if https_proxy = System.get_env("HTTPS_PROXY"), do: proxy(https_proxy)
407407

408-
# We are using relaxed: true because some clients (namely Github pages
409-
# which we are using to download rebar) is returning a Location header
410-
# with relative paths, which does not follow the spec. This would cause
411-
# the request to fail with {:error, :no_scheme} unless :relaxed is given.
408+
# We are using relaxed: true because some clients is returning a Location
409+
# header with relative paths, which does not follow the spec. This would
410+
# cause the request to fail with {:error, :no_scheme} unless :relaxed
411+
# is given.
412412
case :httpc.request(:get, request, [relaxed: true], [body_format: :binary], :mix) do
413413
{:ok, {{_, status, _}, _, body}} when status in 200..299 ->
414414
body
@@ -417,6 +417,7 @@ defmodule Mix.Utils do
417417
{:error, reason} ->
418418
Mix.raise "Could not access url #{path}, error: #{inspect reason}"
419419
end
420+
after
420421
:inets.stop(:httpc, :mix)
421422
end
422423

0 commit comments

Comments
 (0)