Browse files

Merge branch 'master' of git://github.com/timpritlove/prittorrent

Conflicts:
	src/tracker_web.erl
  • Loading branch information...
2 parents ae0ae5f + 4ff5d12 commit d2bdc1c716d1eb9d27c5a0305731979e532c35d9 @monkeydom monkeydom committed Mar 13, 2011
Showing with 8 additions and 2 deletions.
  1. +1 −1 src/tracker_client.erl
  2. +1 −0 src/tracker_web.erl
  3. +6 −1 src/trackerdb.erl
View
2 src/tracker_client.erl
@@ -73,7 +73,7 @@ request(Url, InfoHash, PeerId, Port, Uploaded, Downloaded, Left, Event) ->
logger:log(control, debug,
"Tracker request to: ~s", [Url2]),
- {ok,{{_,200,_},_,Body}} = http:request(Url2),
+ {ok,{{_,200,_},_,Body}} = httpc:request(Url2),
benc:parse(list_to_binary(Body)).
get_param([]) ->
View
1 src/tracker_web.erl
@@ -51,6 +51,7 @@ loop(Req) ->
{<<"peers">>, PeersContent}])
end,
io:format("Response: ~s~n", [Response]),
+
Req:ok({"text/plain", Response});
_ ->
Req:respond({501, [{"Content-Type", "text/plain"}], "Malformed request."})
View
7 src/trackerdb.erl
@@ -30,7 +30,12 @@ announce(InfoHash, Ip, Port, PeerId, Uploaded, Downloaded, Left) ->
AvailablePeers = [ { TmpPeerId, TmpIp, TmpPort } ||
Peer = #pirate{ peer_id = TmpPeerId, ip = TmpIp, port = TmpPort } <- AllPeers, Peer#pirate.id =/= PrimaryPeerKey],
- Complete = 0, Incomplete = 0,
+ { Complete, Incomplete } = mnesia:foldl(
+ fun(#pirate{left = 0}, { CompleteAcc, IncompleteAcc} ) ->
+ { CompleteAcc + 1, IncompleteAcc };
+ (_, { CompleteAcc, IncompleteAcc} ) ->
+ { CompleteAcc , IncompleteAcc + 1 }
+ end, { 0, 0}, pirate),
{ ok, AvailablePeers, Complete, Incomplete }
end),
Result.

0 comments on commit d2bdc1c

Please sign in to comment.