Skip to content

Remove duplicate call to mkdir in concurrency lock #14175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading