Skip to content

Commit

Permalink
Remove duplicate call to mkdir in concurrency lock (#14175)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko authored Jan 11, 2025
1 parent 821ac12 commit 04a662a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
5 changes: 2 additions & 3 deletions lib/mix/lib/mix/sync/lock.ex
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,9 @@ defmodule Mix.Sync.Lock do
end

defp base_path do
# We include user in the dir to avoid permission conflicts across users
user = System.get_env("USER", "default")
path = Path.join([System.tmp_dir!(), "mix_lock_#{Base.url_encode64(user, padding: false)}"])
File.mkdir_p!(path)
path
Path.join(System.tmp_dir!(), "mix_lock_#{Base.url_encode64(user, padding: false)}")
end

defp lock_disabled?(), do: System.get_env("MIX_OS_CONCURRENCY_LOCK") in ~w(0 false)
Expand Down
13 changes: 6 additions & 7 deletions lib/mix/lib/mix/sync/pubsub.ex
Original file line number Diff line number Diff line change
Expand Up @@ -272,18 +272,17 @@ defmodule Mix.Sync.PubSub do

defp hash(key), do: :erlang.md5(key)

defp base_path do
user = System.get_env("USER", "default")
path = Path.join([System.tmp_dir!(), "mix_pubsub_#{Base.url_encode64(user, padding: false)}"])
File.mkdir_p!(path)
path
end

defp path(hash) do
hash = Base.url_encode64(hash, padding: false)
Path.join(base_path(), hash)
end

defp base_path do
# We include user in the dir to avoid permission conflicts across users
user = System.get_env("USER", "default")
Path.join(System.tmp_dir!(), "mix_pubsub_#{Base.url_encode64(user, padding: false)}")
end

defp recv(socket, size, timeout \\ :infinity) do
# eintr is "Interrupted system call".
with {:error, :eintr} <- :gen_tcp.recv(socket, size, timeout) do
Expand Down

0 comments on commit 04a662a

Please sign in to comment.