From 3924908f64dec6fdd9c8195b826453602f7b34f1 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 20 Sep 2014 14:01:22 -0500 Subject: more efficient check for existing dep --- src/rebar_app_utils.erl | 3 +++ src/rebar_prv_install_deps.erl | 22 ++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index 8c78850..d1487fb 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -27,6 +27,7 @@ -module(rebar_app_utils). -export([find/2, + find/3, is_app_dir/0, is_app_dir/1, is_app_src/1, app_src_to_app/1, @@ -54,9 +55,11 @@ find(Name, Vsn, Apps) -> andalso rebar_app_info:original_vsn(App) =:= Vsn end, Apps). +-spec is_app_dir() -> {true, file:name()} | false. is_app_dir() -> is_app_dir(rebar_utils:get_cwd()). +-spec is_app_dir(file:name()) -> {true, file:name()} | false. is_app_dir(Dir) -> SrcDir = filename:join([Dir, "src"]), AppSrc = filename:join([SrcDir, "*.app.src"]), diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 607aeb7..ef08754 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -176,16 +176,22 @@ handle_dep(DepsDir, AppInfo) -> {AppInfo1, SrcDeps, BinaryDeps}. -spec maybe_fetch(rebar_app_info:t(), rebar_state:t()) -> ok. -maybe_fetch(AppInfo, State) -> - AppDir = rebar_app_info:dir(AppInfo), - Apps = rebar_app_discover:find_apps([get_deps_dir(State)], all), - case rebar_app_utils:find(rebar_app_info:name(AppInfo), Apps) of - {ok, _} -> +maybe_fetch(AppInfo, _State) -> + AppDir = ec_cnv:to_list(rebar_app_info:dir(AppInfo)), + %Apps = rebar_app_discover:find_apps([get_deps_dir(State)], all), + %case rebar_app_utils:find(rebar_app_info:name(AppInfo), Apps) of + case rebar_app_utils:is_app_dir(filename:absname(AppDir)++"-*") of + {true, _} -> ok; _ -> - ?INFO("Fetching ~s~n", [rebar_app_info:name(AppInfo)]), - Source = rebar_app_info:source(AppInfo), - rebar_fetch:download_source(AppDir, Source) + case rebar_app_utils:is_app_dir(filename:absname(AppDir)) of + {true, _} -> + ok; + _ -> + ?INFO("Fetching ~s~n", [rebar_app_info:name(AppInfo)]), + Source = rebar_app_info:source(AppInfo), + rebar_fetch:download_source(AppDir, Source) + end end. -spec parse_deps(binary(), [dep()]) -> {ordsets:ordset(rebar_app_info:t()), [binary_dep()]}. -- cgit v1.1