summaryrefslogtreecommitdiff
path: root/src/rebar_packages.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_packages.erl')
-rw-r--r--src/rebar_packages.erl19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/rebar_packages.erl b/src/rebar_packages.erl
index 30d11c9..38dfbbf 100644
--- a/src/rebar_packages.erl
+++ b/src/rebar_packages.erl
@@ -13,18 +13,27 @@
-spec get_packages(rebar_state:t()) -> {rebar_dict(), rebar_digraph()}.
get_packages(State) ->
RebarDir = rebar_dir:global_config_dir(State),
- PackagesFile = filename:join(RebarDir, "packages"),
- case ec_file:exists(PackagesFile) of
+ RegistryDir = filename:join(RebarDir, "packages"),
+ DictFile = filename:join(RegistryDir, "dict"),
+ Edges = filename:join(RegistryDir, "edges"),
+ Vertices = filename:join(RegistryDir, "vertices"),
+ Neighbors = filename:join(RegistryDir, "neighbors"),
+
+ case lists:all(fun(X) -> filelib:is_file(X) end, [DictFile, Edges, Vertices, Neighbors]) of
true ->
try
- {ok, Binary} = file:read_file(PackagesFile),
- {Dict, Graph} = binary_to_term(Binary),
- {Dict, rebar_digraph:restore_graph(Graph)}
+ {ok, DictBinary} = file:read_file(DictFile),
+ Dict = binary_to_term(DictBinary),
+ {ok, EdgesTab} = ets:file2tab(Edges),
+ {ok, VerticesTab} = ets:file2tab(Vertices),
+ {ok, NeighborsTab} = ets:file2tab(Neighbors),
+ {Dict, {digraph, EdgesTab, VerticesTab, NeighborsTab, true}}
catch
_:_ ->
?ERROR("Bad packages index, try to fix with `rebar3 update`", []),
{dict:new(), digraph:new()}
end;
false ->
+ ?ERROR("Bad packages index, try to fix with `rebar3 update`", []),
{dict:new(), digraph:new()}
end.