summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2016-10-04 22:34:22 -0400
committerFred Hebert <mononcqc@ferd.ca>2016-10-04 22:34:22 -0400
commit1f86ed1aed990438103c5f668c4ec930ab637fc9 (patch)
treef776e22401f1a593bd4f24fe189e6e854b2102e4 /src
parent45d9127dc952430d4b519741cb2303953e302665 (diff)
Track package hash in memory index, add hash test
This adds tracking of package hash in the in-memory index rather than the current `undefined' values. According to the test added, this is not necessary for transitive package dep hash chcking, but does result in a more complete index search result when doing app lookups, and could yield some optimizations on hash checks by checking from the index structure before fetching a package.
Diffstat (limited to 'src')
-rw-r--r--src/rebar_prv_update.erl18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl
index ff7194a..75c609e 100644
--- a/src/rebar_prv_update.erl
+++ b/src/rebar_prv_update.erl
@@ -104,7 +104,8 @@ hex_to_index(State) ->
case lists:any(fun is_supported/1, BuildTools) of
true ->
DepsList = update_deps_list(Pkg, PkgVsn, Deps, Registry, State),
- ets:insert(?PACKAGE_TABLE, {{Pkg, PkgVsn}, DepsList, Checksum});
+ HashedDeps = update_deps_hashes(DepsList),
+ ets:insert(?PACKAGE_TABLE, {{Pkg, PkgVsn}, HashedDeps, Checksum});
false ->
true
end;
@@ -176,6 +177,21 @@ update_deps_list(Pkg, PkgVsn, Deps, HexRegistry, State) ->
DepsListAcc
end, [], Deps).
+update_deps_hashes(List) ->
+ [{Name, {pkg, PkgName, Vsn, lookup_hash(PkgName, Vsn, Hash)}}
+ || {Name, {pkg, PkgName, Vsn, Hash}} <- List].
+
+lookup_hash(Name, Vsn, undefined) ->
+ try
+ ets:lookup_element(?PACKAGE_TABLE, {Name, Vsn}, 3)
+ catch
+ _:_ ->
+ undefined
+ end;
+lookup_hash(_, _, Hash) ->
+ Hash.
+
+
rm_ws(<<" ", R/binary>>) ->
rm_ws(R);
rm_ws(R) ->