diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2014-12-05 19:51:02 -0500 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2014-12-05 19:51:02 -0500 |
commit | 018c5ceba35c3af4af9b38f614e4530a2ce99db4 (patch) | |
tree | 51fb8cfca20714bddcd7567eb17296bcbf6c2f48 /src/rebar_fetch.erl | |
parent | 228e96c9eb296d236ec23dfc1ee0e6b5236c4a30 (diff) | |
parent | 91860340bb66d240f207eef1306778dde6fe3edc (diff) |
Merge pull request #42 from tsloughter/master
Update error message and fix order of dir creation for deps
Diffstat (limited to 'src/rebar_fetch.erl')
-rw-r--r-- | src/rebar_fetch.erl | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/rebar_fetch.erl b/src/rebar_fetch.erl index 2df892c..eac2d02 100644 --- a/src/rebar_fetch.erl +++ b/src/rebar_fetch.erl @@ -11,6 +11,8 @@ download_source/2, needs_update/2]). +-export([format_error/1]). + -include("rebar.hrl"). %% map short versions of resources to module names @@ -28,14 +30,15 @@ download_source(AppDir, Source) -> Module = get_resource_type(Source), TmpDir = ec_file:insecure_mkdtemp(), AppDir1 = ec_cnv:to_list(AppDir), - ec_file:mkdir_p(AppDir1), case Module:download(TmpDir, Source) of {ok, _} -> + ec_file:mkdir_p(AppDir1), code:del_path(filename:absname(filename:join(AppDir1, "ebin"))), ec_file:remove(filename:absname(AppDir1), [recursive]), ok = ec_file:copy(TmpDir, filename:absname(AppDir1), [recursive]), true; {tarball, File} -> + ec_file:mkdir_p(AppDir1), ok = erl_tar:extract(File, [{cwd, TmpDir} ,compressed]), BaseName = filename:basename(AppDir1), @@ -46,8 +49,8 @@ download_source(AppDir, Source) -> true end catch - _:E -> - {error, E} + _:_ -> + {error, {rebar_fetch, {fetch_fail, Source}}} end. -spec needs_update(file:filename_all(), rebar_resource:resource()) -> boolean() | {error, string()}. @@ -60,6 +63,9 @@ needs_update(AppDir, Source) -> true end. +format_error({fetch_fail, Source}) -> + io_lib:format("Failed to fetch and copy dep: ~p", [Source]). + get_resource_type({Type, Location}) -> find_resource_module(Type, Location); get_resource_type({Type, Location, _}) -> |