diff options
-rw-r--r-- | src/rebar_prv_update.erl | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl index ce6350b..e57f19d 100644 --- a/src/rebar_prv_update.erl +++ b/src/rebar_prv_update.erl @@ -35,11 +35,14 @@ do(State) -> ?INFO("Updating package index...", []), try Url = url(State), + TmpDir = ec_file:insecure_mkdtemp(), + TmpFile = filename:join(TmpDir, "packages"), Home = rebar_utils:home_dir(), PackagesFile = filename:join([Home, ?CONFIG_DIR, "packages"]), filelib:ensure_dir(PackagesFile), - {ok, _RequestId} = httpc:request(get, {Url, []}, [], [{stream, PackagesFile} - ,{sync, true}]) + {ok, _RequestId} = httpc:request(get, {Url, []}, [], [{stream, TmpFile} + ,{sync, true}]), + ok = ec_file:copy(TmpFile, PackagesFile) catch _:_ -> {error, {?MODULE, package_index_write}} |