summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2016-08-27 16:04:33 -0400
committerGitHub <noreply@github.com>2016-08-27 16:04:33 -0400
commit4347f48e7fc7f0939b37fe984f1286f332735630 (patch)
treebf30b8586839abb5080d29b338160b562b4dfa11
parent00b10530584135888e9a40c186b049f76c226028 (diff)
parent6bd8cda77aaa089f9eaa87dd696cfa63af5f2292 (diff)
Merge pull request #1315 from ferd/fix-hashcheck-noindex
Fix crash when doing hash check with missing index
-rw-r--r--src/rebar_app_utils.erl11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl
index 50c6314..847b0a5 100644
--- a/src/rebar_app_utils.erl
+++ b/src/rebar_app_utils.erl
@@ -190,7 +190,7 @@ update_source(AppInfo, {pkg, PkgName, PkgVsn, Hash}, State) ->
%% store the expected hash for the dependency
Hash1 = case Hash of
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
Hash
end,
@@ -203,6 +203,15 @@ update_source(AppInfo, {pkg, PkgName, PkgVsn, Hash}, State) ->
update_source(AppInfo, Source, _State) ->
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}) ->
io_lib:format("Package not found in registry: ~s", [Package]);