@@ -5,24 +5,51 @@ defmodule Hex.API.ReleaseDocs do
55
66 def get ( repo , name , version ) do
77 config = build_config ( repo , [ ] )
8- path = :mix_hex_api . build_repository_path ( config , [ "packages" , to_string ( name ) , "releases" , to_string ( version ) , "docs" ] )
8+
9+ path =
10+ :mix_hex_api . build_repository_path ( config , [
11+ "packages" ,
12+ to_string ( name ) ,
13+ "releases" ,
14+ to_string ( version ) ,
15+ "docs"
16+ ] )
917
1018 :mix_hex_api . get ( config , path )
1119 end
1220
13- def publish ( repo , name , version , tar , auth , _progress \\ fn _ -> nil end ) do
21+ def publish ( repo , name , version , tar , auth , progress \\ fn _ -> nil end ) do
1422 config = build_config ( repo , auth )
15- path = :mix_hex_api . build_repository_path ( config , [ "packages" , to_string ( name ) , "releases" , to_string ( version ) , "docs" ] )
23+
24+ # Pass progress callback through adapter config
25+ adapter_config = % { progress_callback: progress }
26+ config = Map . put ( config , :http_adapter , { Hex.HTTP , adapter_config } )
27+
28+ path =
29+ :mix_hex_api . build_repository_path ( config , [
30+ "packages" ,
31+ to_string ( name ) ,
32+ "releases" ,
33+ to_string ( version ) ,
34+ "docs"
35+ ] )
1636
1737 body = { "application/octet-stream" , tar }
1838
19- # TODO: Progress callback needs to be handled differently
2039 :mix_hex_api . post ( config , path , body )
2140 end
2241
2342 def delete ( repo , name , version , auth ) do
2443 config = build_config ( repo , auth )
25- path = :mix_hex_api . build_repository_path ( config , [ "packages" , to_string ( name ) , "releases" , to_string ( version ) , "docs" ] )
44+
45+ path =
46+ :mix_hex_api . build_repository_path ( config , [
47+ "packages" ,
48+ to_string ( name ) ,
49+ "releases" ,
50+ to_string ( version ) ,
51+ "docs"
52+ ] )
2653
2754 :mix_hex_api . delete ( config , path )
2855 end
@@ -32,5 +59,4 @@ defmodule Hex.API.ReleaseDocs do
3259 opts = if auth , do: Keyword . merge ( opts , auth ) , else: opts
3360 Client . config ( opts )
3461 end
35-
3662end
0 commit comments