Skip to content

Commit 6657e7f

Browse files
authored
Track mix_pubsub and mix_lock folders per user (#14171)
1 parent 7589754 commit 6657e7f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ defmodule Mix.Sync.Lock do
9797
opts = Keyword.validate!(opts, [:on_taken])
9898

9999
hash = key |> :erlang.md5() |> Base.url_encode64(padding: false)
100-
path = Path.join([System.tmp_dir!(), "mix_lock", hash])
100+
path = Path.join(base_path(), hash)
101101

102102
pdict_key = {__MODULE__, path}
103103
has_lock? = Process.get(pdict_key, false)
@@ -119,6 +119,13 @@ defmodule Mix.Sync.Lock do
119119
end
120120
end
121121

122+
defp base_path do
123+
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
127+
end
128+
122129
defp lock_disabled?(), do: System.get_env("MIX_OS_CONCURRENCY_LOCK") in ~w(0 false)
123130

124131
defp lock(path, on_taken) do

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,16 @@ 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+
275282
defp path(hash) do
276283
hash = Base.url_encode64(hash, padding: false)
277-
Path.join([System.tmp_dir!(), "mix_pubsub", hash])
284+
Path.join(base_path(), hash)
278285
end
279286

280287
defp recv(socket, size, timeout \\ :infinity) do

0 commit comments

Comments
 (0)