File tree Expand file tree Collapse file tree 2 files changed +10
-16
lines changed Expand file tree Collapse file tree 2 files changed +10
-16
lines changed Original file line number Diff line number Diff line change @@ -97,9 +97,7 @@ defmodule Mix.Sync.Lock do
97
97
opts = Keyword . validate! ( opts , [ :on_taken ] )
98
98
99
99
hash = key |> :erlang . md5 ( ) |> Base . url_encode64 ( padding: false )
100
- base_path = Path . join ( [ System . tmp_dir! ( ) , "mix_lock" ] )
101
- init_base_path ( base_path )
102
- path = Path . join ( [ base_path , hash ] )
100
+ path = Path . join ( base_path ( ) , hash )
103
101
104
102
pdict_key = { __MODULE__ , path }
105
103
has_lock? = Process . get ( pdict_key , false )
@@ -121,10 +119,11 @@ defmodule Mix.Sync.Lock do
121
119
end
122
120
end
123
121
124
- defp init_base_path ( path ) do
122
+ defp base_path do
123
+ user = System . get_env ( "USER" , "default" )
124
+ path = Path . join ( [ System . tmp_dir! ( ) , "mix_pubsub_#{ Base . url_encode64 ( user , padding: false ) } " ] )
125
125
File . mkdir_p! ( path )
126
- # ensure other users can write to the directory
127
- _ = File . chmod ( path , 0o777 )
126
+ path
128
127
end
129
128
130
129
defp lock_disabled? ( ) , do: System . get_env ( "MIX_OS_CONCURRENCY_LOCK" ) in ~w( 0 false)
Original file line number Diff line number Diff line change @@ -127,7 +127,6 @@ defmodule Mix.Sync.PubSub do
127
127
@ impl true
128
128
def init ( { } ) do
129
129
state = % { port: nil , hash_to_pids: % { } }
130
- init_base_path ( )
131
130
{ :ok , state }
132
131
end
133
132
@@ -274,19 +273,15 @@ defmodule Mix.Sync.PubSub do
274
273
defp hash ( key ) , do: :erlang . md5 ( key )
275
274
276
275
defp base_path do
277
- Path . join ( System . tmp_dir! ( ) , "mix_pubsub" )
276
+ user = System . get_env ( "USER" , "default" )
277
+ path = Path . join ( [ System . tmp_dir! ( ) , "mix_lock_#{ Base . url_encode64 ( user , padding: false ) } " ] )
278
+ File . mkdir_p! ( path )
279
+ path
278
280
end
279
281
280
282
defp path ( hash ) do
281
283
hash = Base . url_encode64 ( hash , padding: false )
282
- Path . join ( [ base_path ( ) , hash ] )
283
- end
284
-
285
- defp init_base_path do
286
- path = base_path ( )
287
- File . mkdir_p! ( path )
288
- # ensure other users can write to the directory
289
- _ = File . chmod ( path , 0o777 )
284
+ Path . join ( base_path ( ) , hash )
290
285
end
291
286
292
287
defp recv ( socket , size , timeout \\ :infinity ) do
You can’t perform that action at this time.
0 commit comments