Skip to content

Commit 9593cef

Browse files
jonatankloskojosevalim
authored andcommitted
Remove duplicate call to mkdir in concurrency lock (#14175)
1 parent c78f426 commit 9593cef

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

lib/mix/lib/mix/sync/lock.ex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,9 @@ defmodule Mix.Sync.Lock do
120120
end
121121

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

129128
defp lock_disabled?(), do: System.get_env("MIX_OS_CONCURRENCY_LOCK") in ~w(0 false)

lib/mix/lib/mix/sync/pubsub.ex

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,18 +272,17 @@ defmodule Mix.Sync.PubSub do
272272

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

275-
defp base_path do
276-
user = System.get_env("USER", "default")
277-
path = Path.join([System.tmp_dir!(), "mix_pubsub_#{Base.url_encode64(user, padding: false)}"])
278-
File.mkdir_p!(path)
279-
path
280-
end
281-
282275
defp path(hash) do
283276
hash = Base.url_encode64(hash, padding: false)
284277
Path.join(base_path(), hash)
285278
end
286279

280+
defp base_path do
281+
# We include user in the dir to avoid permission conflicts across users
282+
user = System.get_env("USER", "default")
283+
Path.join(System.tmp_dir!(), "mix_pubsub_#{Base.url_encode64(user, padding: false)}")
284+
end
285+
287286
defp recv(socket, size, timeout \\ :infinity) do
288287
# eintr is "Interrupted system call".
289288
with {:error, :eintr} <- :gen_tcp.recv(socket, size, timeout) do

0 commit comments

Comments
 (0)