Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/mix_hex_api.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% @doc
%% Hex HTTP API
Expand Down
2 changes: 1 addition & 1 deletion src/mix_hex_api_auth.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% @doc
%% Hex HTTP API - Authentication.
Expand Down
2 changes: 1 addition & 1 deletion src/mix_hex_api_key.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% @doc
%% Hex HTTP API - Keys.
Expand Down
2 changes: 1 addition & 1 deletion src/mix_hex_api_oauth.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% @doc
%% Hex HTTP API - OAuth.
Expand Down
2 changes: 1 addition & 1 deletion src/mix_hex_api_organization.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% @doc
%% Hex HTTP API - Organizations.
Expand Down
2 changes: 1 addition & 1 deletion src/mix_hex_api_organization_member.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% @doc
%% Hex HTTP API - Organization Members.
Expand Down
2 changes: 1 addition & 1 deletion src/mix_hex_api_package.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% @doc
%% Hex HTTP API - Packages.
Expand Down
2 changes: 1 addition & 1 deletion src/mix_hex_api_package_owner.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% @doc
%% Hex HTTP API - Package Owners.
Expand Down
2 changes: 1 addition & 1 deletion src/mix_hex_api_release.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% @doc
%% Hex HTTP API - Releases.
Expand Down
2 changes: 1 addition & 1 deletion src/mix_hex_api_short_url.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% @doc
%% Hex HTTP API - Short URLs.
Expand Down
2 changes: 1 addition & 1 deletion src/mix_hex_api_user.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% @doc
%% Hex HTTP API - Users.
Expand Down
23 changes: 15 additions & 8 deletions src/mix_hex_core.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% @doc
%% `hex_core' entrypoint module.
Expand Down Expand Up @@ -69,15 +69,20 @@
%% `134_217_728' (128 MiB). Set to `infinity' to not enforce the limit.
%%
%% * `tarball_files_root' - Root directory for source files when creating tarballs.
%% Required for filesystem source paths, which must be relative and must resolve inside
%% this root after following symlinks. Set to `undefined' when all tarball contents are
%% provided as binaries and no filesystem source paths are used (default: `undefined').
%% Filesystem source paths must resolve inside this root after following symlinks.
%% Relative source paths are resolved from this root and absolute source paths must be
%% inside it (default: `"."').
%%
%% * `docs_tarball_max_size' - Maximum size of docs tarball, defaults to
%% `16_777_216' (16 MiB). Set to `infinity' to not enforce the limit.
%%
%% * `docs_tarball_max_uncompressed_size' - Maximum size of uncompressed docs tarball, defaults to
%% `134_217_728' (128 MiB). Set to `infinity' to not enforce the limit.
%%
%% * `metadata_fields' - Either `all' or a list of metadata.config keys (binaries) to read.
%% When set to a list, the metadata decoder streams past unrequested fields without
%% buffering their tokens, which keeps peak memory bounded for packages with very
%% large fields like `<<"files">>'. Defaults to `all'.

-module(mix_hex_core).
-export([default_config/0]).
Expand Down Expand Up @@ -115,11 +120,12 @@
repo_verify => boolean(),
repo_verify_origin => boolean(),
send_100_continue => boolean(),
tarball_files_root => file:filename() | undefined,
tarball_files_root => file:filename(),
tarball_max_size => pos_integer() | infinity,
tarball_max_uncompressed_size => pos_integer() | infinity,
docs_tarball_max_size => pos_integer() | infinity,
docs_tarball_max_uncompressed_size => pos_integer() | infinity
docs_tarball_max_uncompressed_size => pos_integer() | infinity,
metadata_fields => all | [binary()]
}.

-spec default_config() -> config().
Expand All @@ -142,9 +148,10 @@ default_config() ->
repo_verify => true,
repo_verify_origin => true,
send_100_continue => true,
tarball_files_root => undefined,
tarball_files_root => ".",
tarball_max_size => 16 * 1024 * 1024,
tarball_max_uncompressed_size => 128 * 1024 * 1024,
docs_tarball_max_size => 16 * 1024 * 1024,
docs_tarball_max_uncompressed_size => 128 * 1024 * 1024
docs_tarball_max_uncompressed_size => 128 * 1024 * 1024,
metadata_fields => all
}.
4 changes: 2 additions & 2 deletions src/mix_hex_core.hrl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

-define(HEX_CORE_VERSION, "0.15.0").
-define(HEX_CORE_VERSION, "0.16.0").
2 changes: 1 addition & 1 deletion src/mix_hex_erl_tar.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% This file is a copy of erl_tar.erl from OTP with the following modifications:
%% 1. Module renamed from erl_tar to mix_hex_erl_tar
Expand Down
2 changes: 1 addition & 1 deletion src/mix_hex_erl_tar.hrl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% This file is a copy of erl_tar.hrl from OTP with the following modifications:
%% 1. Added chunk_size field to #read_opts{} for streaming extraction to disk
Expand Down
2 changes: 1 addition & 1 deletion src/mix_hex_http.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% @doc
%% HTTP contract.
Expand Down
44 changes: 37 additions & 7 deletions src/mix_hex_http_httpc.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% @doc
%% httpc-based implementation of {@link mix_hex_http} contract.
Expand Down Expand Up @@ -41,15 +41,12 @@ request_to_file(Method, URI, ReqHeaders, Body, Filename, AdapterConfig) when is_
Method,
Request,
HTTPOptions,
[{stream, unicode:characters_to_list(Filename)}],
[{sync, false}, {stream, self}],
Profile
)
of
{ok, saved_to_file} ->
{ok, {200, #{}}};
{ok, {{_, StatusCode, _}, RespHeaders, _RespBody}} ->
RespHeaders2 = load_headers(RespHeaders),
{ok, {StatusCode, RespHeaders2}};
{ok, RequestId} ->
stream_to_file(RequestId, Filename);
{error, Reason} ->
{error, Reason}
end.
Expand All @@ -58,6 +55,39 @@ request_to_file(Method, URI, ReqHeaders, Body, Filename, AdapterConfig) when is_
%% Internal functions
%%====================================================================

%% @private
%% httpc streams 200/206 responses as messages and returns non-2xx as
%% a normal response tuple. stream_start includes the response headers.
stream_to_file(RequestId, Filename) ->
receive
{http, {RequestId, stream_start, Headers}} ->
{ok, File} = file:open(Filename, [write, binary]),
case stream_body(RequestId, File) of
ok ->
ok = file:close(File),
{ok, {200, load_headers(Headers)}};
{error, Reason} ->
ok = file:close(File),
{error, Reason}
end;
{http, {RequestId, {{_, StatusCode, _}, RespHeaders, _RespBody}}} ->
{ok, {StatusCode, load_headers(RespHeaders)}};
{http, {RequestId, {error, Reason}}} ->
{error, Reason}
end.

%% @private
stream_body(RequestId, File) ->
receive
{http, {RequestId, stream, BinBodyPart}} ->
ok = file:write(File, BinBodyPart),
stream_body(RequestId, File);
{http, {RequestId, stream_end, _Headers}} ->
ok;
{http, {RequestId, {error, Reason}}} ->
{error, Reason}
end.

%% @private
http_options(URI, AdapterConfig) ->
HTTPOptions0 = maps:get(http_options, AdapterConfig, []),
Expand Down
2 changes: 1 addition & 1 deletion src/mix_hex_licenses.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (4ff8378), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% @doc
%% Hex Licenses.
Expand Down
2 changes: 1 addition & 1 deletion src/mix_hex_pb_names.erl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% Vendored from hex_core v0.15.0 (90f9f59), do not edit manually
%% Vendored from hex_core v0.16.0 (0e332e5), do not edit manually

%% -*- coding: utf-8 -*-
%% % this file is @generated
Expand Down
Loading
Loading