浏览代码

Fix crash when doing hash check with missing index

Specifically, when fetching an application where the expected hash is
unknown, the hash is validated from the hex index; when the index is
available, the hash is fetched fine and later inserted in the lock file.

However, if the index is not available, the call would simply crash.
This patch fixes thing so that instead, the index is refreshed before
giving up and failing.
pull/1315/head
Fred Hebert 8 年前
父节点
当前提交
6bd8cda77a
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. +10
    -1
      src/rebar_app_utils.erl

+ 10
- 1
src/rebar_app_utils.erl 查看文件

@ -190,7 +190,7 @@ update_source(AppInfo, {pkg, PkgName, PkgVsn, Hash}, State) ->
%% store the expected hash for the dependency %% store the expected hash for the dependency
Hash1 = case Hash of Hash1 = case Hash of
undefined -> % unknown, define the hash since we know the dep undefined -> % unknown, define the hash since we know the dep
rebar_packages:registry_checksum({pkg, PkgName1, PkgVsn1, Hash}, State);
fetch_checksum(PkgName1, PkgVsn1, Hash, State);
_ -> % keep as is _ -> % keep as is
Hash Hash
end, end,
@ -203,6 +203,15 @@ update_source(AppInfo, {pkg, PkgName, PkgVsn, Hash}, State) ->
update_source(AppInfo, Source, _State) -> update_source(AppInfo, Source, _State) ->
rebar_app_info:source(AppInfo, Source). rebar_app_info:source(AppInfo, Source).
fetch_checksum(PkgName, PkgVsn, Hash, State) ->
try
rebar_packages:registry_checksum({pkg, PkgName, PkgVsn, Hash}, State)
catch
_:_ ->
?INFO("Package ~s-~s not found. Fetching registry updates and trying again...", [PkgName, PkgVsn]),
{ok, _} = rebar_prv_update:do(State),
rebar_packages:registry_checksum({pkg, PkgName, PkgVsn, Hash}, State)
end.
format_error({missing_package, Package}) -> format_error({missing_package, Package}) ->
io_lib:format("Package not found in registry: ~s", [Package]); io_lib:format("Package not found in registry: ~s", [Package]);

正在加载...
取消
保存