Browse Source

Merge pull request #1761 from ferd/fix-local-upgrade-etag

Fix local upgrade etag handling
pull/1764/head
Fred Hebert 7 years ago
committed by GitHub
parent
commit
dc6207f5b5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions
  1. +10
    -1
      src/rebar_prv_local_upgrade.erl

+ 10
- 1
src/rebar_prv_local_upgrade.erl View File

@ -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.

Loading…
Cancel
Save