Skip to content

Commit a07c1af

Browse files
committed
Clean up
1 parent d3453c3 commit a07c1af

File tree

3 files changed

+5
-25
lines changed

3 files changed

+5
-25
lines changed

lib/hex/api/client.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ defmodule Hex.API.Client do
99
http_user_agent_fragment: user_agent_fragment()
1010
}
1111

12-
config = maybe_put_api_key(config, opts)
13-
config = maybe_put_organization(config, opts)
14-
config = maybe_put_repository(config, opts)
1512
config
13+
|> maybe_put_api_key(opts)
14+
|> maybe_put_organization(opts)
15+
|> maybe_put_repository(opts)
1616
end
1717

1818
defp maybe_put_api_key(config, opts) do

lib/hex/http.ex

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ defmodule Hex.HTTP do
66
@request_timeout 15_000
77
@request_redirects 3
88
@request_retries 2
9+
@chunk_size 10_000
910

1011
@spec config() :: :mix_hex_core.config()
1112
def config do
@@ -383,15 +384,11 @@ defmodule Hex.HTTP do
383384
end
384385
end
385386

386-
@chunk_size 10_000
387-
388387
defp wrap_body_with_progress(body, progress_callback) do
389388
case body do
390389
{content_type, binary_body}
391390
when is_binary(binary_body) and is_function(progress_callback, 1) ->
392-
# Create streaming function for httpc chunked upload - match old API pattern exactly
393391
total_size = byte_size(binary_body)
394-
# Initialize progress bar
395392
progress_callback.(0)
396393

397394
body_fn = fn
@@ -405,13 +402,11 @@ defmodule Hex.HTTP do
405402
:eof
406403
end
407404

408-
# Return chunked body AND content-length header (required for chunked uploads)
409405
body_result = {content_type, {body_fn, 0}}
410406
headers = %{"content-length" => Integer.to_string(total_size)}
411407
{body_result, headers}
412408

413409
_other ->
414-
# No progress callback or not a binary body, use as-is
415410
{body, %{}}
416411
end
417412
end

lib/mix/tasks/hex.user.ex

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -280,22 +280,7 @@ defmodule Mix.Tasks.Hex.User do
280280

281281
case Hex.API.Key.delete_all(auth) do
282282
{:ok, {code, _headers, body}} when code in 200..299 ->
283-
auth_key_deleted =
284-
cond do
285-
is_list(body) ->
286-
Enum.any?(body, fn
287-
item when is_map(item) -> Map.get(item, "authing_key") == true
288-
_ -> false
289-
end)
290-
291-
is_map(body) ->
292-
Map.get(body, "authing_key") == true
293-
294-
true ->
295-
false
296-
end
297-
298-
if auth_key_deleted do
283+
if Map.get(body, "authing_key") == true do
299284
Mix.Tasks.Hex.User.run(["deauth"])
300285
end
301286

0 commit comments

Comments
 (0)