From b7d7c0eb8bfd9f09af3f3ed02a1982f3d333d50a Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Sat, 21 Apr 2018 09:26:58 -0400 Subject: 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. --- src/rebar_prv_local_upgrade.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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} -> + <> = crypto:hash(md5, Binary), + rebar_string:lowercase(lists:flatten(io_lib:format("~32.16.0b", [X]))); + {error, _} -> + false + end. -- cgit v1.1