mirror of
https://github.com/btdig/dhtcrawler2.git
synced 2025-01-31 10:31:37 +00:00
fix cache_indexer download error
This commit is contained in:
parent
75841f8237
commit
1dc4a2c588
@ -4,6 +4,7 @@
|
|||||||
%% 07.14.2013
|
%% 07.14.2013
|
||||||
%%
|
%%
|
||||||
-module(index_download).
|
-module(index_download).
|
||||||
|
-include("vlog.hrl").
|
||||||
-export([download/0, download/2, do_download/2]).
|
-export([download/0, download/2, do_download/2]).
|
||||||
-define(DOMAIN, "http://torrage.com").
|
-define(DOMAIN, "http://torrage.com").
|
||||||
|
|
||||||
@ -19,9 +20,14 @@ do_download(From, {_, _, _} = Date) ->
|
|||||||
URL = format_file_url(?DOMAIN, File),
|
URL = format_file_url(?DOMAIN, File),
|
||||||
io:format("download file ~s~n", [URL]),
|
io:format("download file ~s~n", [URL]),
|
||||||
Start = now(),
|
Start = now(),
|
||||||
{ok, Code, _, Body} = ibrowse:send_req(URL, [], get, [], [], infinity),
|
case ibrowse:send_req(URL, [], get, [], [], infinity) of
|
||||||
Ret = check_result(File, Code, Body, timer:now_diff(now(), Start) div 1000),
|
{ok, Code, _, Body} ->
|
||||||
From ! Ret.
|
Ret = check_result(File, Code, Body, timer:now_diff(now(), Start) div 1000),
|
||||||
|
From ! Ret;
|
||||||
|
{error, Reason} ->
|
||||||
|
?E(?FMT("download sync file ~s failed ~p", [URL, Reason])),
|
||||||
|
From ! {sync_torrent_index, failed, File}
|
||||||
|
end.
|
||||||
|
|
||||||
check_result(File, "200", Body, Time) ->
|
check_result(File, "200", Body, Time) ->
|
||||||
Size = length(Body),
|
Size = length(Body),
|
||||||
|
Loading…
Reference in New Issue
Block a user