diff options
author | Tristan Sloughter <t@crashfast.com> | 2019-06-08 07:37:26 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-08 07:37:26 -0600 |
commit | f23e5a423347c0b04d8513410132a875f3767340 (patch) | |
tree | 4af2a0f9b941f3ebf92a50081fe11ce010a930b8 | |
parent | 1328a9a2049bfd511554f21e608444c784b4e6d3 (diff) | |
parent | c8f7d2af537bfb8ddd95c93781c293d93a0fb02b (diff) |
Merge pull request #2010 from relayr/check_hash
Warn when there's mismatch between rebar.lock & original package checksum
-rw-r--r-- | src/rebar_packages.erl | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/rebar_packages.erl b/src/rebar_packages.erl index c7bbfac..c56a362 100644 --- a/src/rebar_packages.erl +++ b/src/rebar_packages.erl @@ -74,13 +74,23 @@ get_package(Dep, Vsn, undefined, Repos, Table, State) -> get_package(Dep, Vsn, '_', Repos, Table, State); get_package(Dep, Vsn, Hash, Repos, Table, State) -> ?MODULE:verify_table(State), - case ets:select(Table, [{#package{key={Dep, ec_semver:parse(Vsn), Repo}, - checksum=Hash, - _='_'}, [], ['$_']} || Repo <- Repos]) of + MatchingPackages = ets:select(Table, [{#package{key={Dep, ec_semver:parse(Vsn), Repo}, + _='_'}, [], ['$_']} || Repo <- Repos]), + PackagesWithProperHash = lists:filter( + fun(#package{key = {_Dep, _Vsn, Repo}, checksum = PkgChecksum}) -> + if (PkgChecksum =/= Hash) andalso (Hash =/= '_') -> + ?WARN("Checksum mismatch for package ~ts-~ts from repo ~ts", [Dep, Vsn, Repo]), + false; + true -> + true + end + end, MatchingPackages + ), + case PackagesWithProperHash of %% have to allow multiple matches in the list for cases that Repo is `_` [Package | _] -> {ok, Package}; - _ -> + [] -> not_found end. @@ -249,7 +259,7 @@ update_package(Name, RepoConfig=#{name := Repo}, State) -> Error -> ?DEBUG("Hex get_package request failed: ~p", [Error]), %% TODO: add better log message. r3_hex_core should export a format_error - ?WARN("Failed to update package from repo ~ts", [Repo]), + ?WARN("Failed to update package ~ts from repo ~ts", [Name, Repo]), fail catch _:Exception -> |