File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,9 @@ 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
- path = Path . join ( [ System . tmp_dir! ( ) , "mix_lock" , hash ] )
100
+ base_path = Path . join ( [ System . tmp_dir! ( ) , "mix_lock" ] )
101
+ init_base_path ( base_path )
102
+ path = Path . join ( [ base_path , hash ] )
101
103
102
104
pdict_key = { __MODULE__ , path }
103
105
has_lock? = Process . get ( pdict_key , false )
@@ -119,6 +121,12 @@ defmodule Mix.Sync.Lock do
119
121
end
120
122
end
121
123
124
+ defp init_base_path ( path ) do
125
+ File . mkdir_p! ( path )
126
+ # ensure other users can write to the directory
127
+ _ = File . chmod ( path , 0o777 )
128
+ end
129
+
122
130
defp lock_disabled? ( ) , do: System . get_env ( "MIX_OS_CONCURRENCY_LOCK" ) in ~w( 0 false)
123
131
124
132
defp lock ( path , on_taken ) do
Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ 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 ( )
130
131
{ :ok , state }
131
132
end
132
133
@@ -272,9 +273,20 @@ defmodule Mix.Sync.PubSub do
272
273
273
274
defp hash ( key ) , do: :erlang . md5 ( key )
274
275
276
+ defp base_path do
277
+ Path . join ( System . tmp_dir! ( ) , "mix_pubsub" )
278
+ end
279
+
275
280
defp path ( hash ) do
276
281
hash = Base . url_encode64 ( hash , padding: false )
277
- Path . join ( [ System . tmp_dir! ( ) , "mix_pubsub" , hash ] )
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 )
278
290
end
279
291
280
292
defp recv ( socket , size , timeout \\ :infinity ) do
You can’t perform that action at this time.
0 commit comments