diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2018-04-21 09:26:58 -0400 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2018-04-21 09:26:58 -0400 |
commit | b7d7c0eb8bfd9f09af3f3ed02a1982f3d333d50a (patch) | |
tree | 55aab3230535ac5c1a04bffe6fd140b202ecf32d | |
parent | d4c529a4702128761f7919a81b7ce88bf39809d9 (diff) |
Fix local upgrade etag handling
Since packages store etags on disk directly, the local install feature
can no longer depend on this; we instead port the etag feature back to
local providers only.
-rw-r--r-- | src/rebar_prv_local_upgrade.erl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/rebar_prv_local_upgrade.erl b/src/rebar_prv_local_upgrade.erl index 1ac3adb..3b3c9cb 100644 --- a/src/rebar_prv_local_upgrade.erl +++ b/src/rebar_prv_local_upgrade.erl @@ -80,7 +80,7 @@ maybe_fetch_rebar3(Rebar3Md5) -> case rebar_pkg_resource:request("https://s3.amazonaws.com/rebar3/rebar3", Rebar3Md5) of {ok, Binary, ETag} -> file:write_file(TmpFile, Binary), - case rebar_pkg_resource:etag(TmpFile) of + case etag(TmpFile) of ETag -> {saved, TmpFile}; _ -> @@ -92,3 +92,12 @@ maybe_fetch_rebar3(Rebar3Md5) -> ?CONSOLE("No upgrade available", []), up_to_date end. + +etag(Path) -> + case file:read_file(Path) of + {ok, Binary} -> + <<X:128/big-unsigned-integer>> = crypto:hash(md5, Binary), + rebar_string:lowercase(lists:flatten(io_lib:format("~32.16.0b", [X]))); + {error, _} -> + false + end. |