mirror of
https://github.com/btdig/dhtcrawler2.git
synced 2025-01-31 10:31:37 +00:00
use safe insert in torrent builder
This commit is contained in:
parent
5d8c198357
commit
b9130ec759
@ -24,15 +24,15 @@
|
||||
% increase the seed and return the new id
|
||||
get_torrent_id(Conn) ->
|
||||
Cmd = {findAndModify, ?COLLNAME, query, {'_id', ?TORRENT_ID_KEY},
|
||||
update, {'$inc', {seed, 1}}, new, false, upsert, true},
|
||||
update, {'$inc', {seed, 1}}, new, true, upsert, true},
|
||||
Ret = mongo:do(safe, master, Conn, ?DBNAME, fun() ->
|
||||
mongo:command(Cmd)
|
||||
end),
|
||||
case bson:lookup(value, Ret) of
|
||||
{undefined} ->
|
||||
0;
|
||||
1;
|
||||
{} ->
|
||||
0;
|
||||
1;
|
||||
{Obj} ->
|
||||
{Seed} = bson:lookup(seed, Obj),
|
||||
Seed
|
||||
|
@ -160,5 +160,5 @@ try_save([]) ->
|
||||
ok;
|
||||
try_save(Tors) ->
|
||||
Conn = mongo_pool:get(?DBPOOL),
|
||||
db_store_mongo:unsafe_insert(Conn, Tors).
|
||||
|
||||
[db_store_mongo:insert(Conn, Hash, Name, Length, Files) ||
|
||||
{Hash, Name, Length, Files} <- Tors].
|
||||
|
Loading…
Reference in New Issue
Block a user