mirror of
https://github.com/transmission/transmission
synced 2024-12-26 17:47:37 +00:00
(trunk libT) don't allow duplicate torrents to be added via magnet links
This commit is contained in:
parent
3610c5ea62
commit
c102f199c3
2 changed files with 15 additions and 7 deletions
|
@ -1872,7 +1872,7 @@ fillOutputBuffer( tr_peermsgs * msgs, time_t now )
|
|||
tr_bencInitDict( &tmp, 3 );
|
||||
tr_bencDictAddInt( &tmp, "msg_type", METADATA_MSG_TYPE_DATA );
|
||||
tr_bencDictAddInt( &tmp, "piece", piece );
|
||||
tr_bencDictAddInt( &tmp, "total_size", dataLen );
|
||||
tr_bencDictAddInt( &tmp, "total_size", msgs->torrent->infoDictLength );
|
||||
payload = tr_bencToStr( &tmp, TR_FMT_BENC, &payloadLen );
|
||||
tr_bencFree( &tmp );
|
||||
|
||||
|
|
|
@ -767,23 +767,31 @@ tr_torrent *
|
|||
tr_torrentNew( const tr_ctor * ctor,
|
||||
int * setmeError )
|
||||
{
|
||||
int err;
|
||||
tr_info tmpInfo;
|
||||
tr_torrent * tor = NULL;
|
||||
const tr_magnet_info * magnetInfo;
|
||||
tr_session * session = tr_ctorGetSession( ctor );
|
||||
|
||||
assert( ctor != NULL );
|
||||
assert( tr_isSession( tr_ctorGetSession( ctor ) ) );
|
||||
assert( tr_isSession( session ) );
|
||||
|
||||
if( !tr_ctorGetMagnet( ctor, &magnetInfo ) )
|
||||
{
|
||||
tor = tr_new0( tr_torrent, 1 );
|
||||
tr_metainfoSetFromMagnet( &tor->info, magnetInfo );
|
||||
torrentInit( tor, ctor );
|
||||
if( tr_torrentFindFromHash( session, magnetInfo->hash ) != NULL )
|
||||
{
|
||||
if( setmeError )
|
||||
*setmeError = TR_PARSE_DUPLICATE;
|
||||
}
|
||||
else
|
||||
{
|
||||
tor = tr_new0( tr_torrent, 1 );
|
||||
tr_metainfoSetFromMagnet( &tor->info, magnetInfo );
|
||||
torrentInit( tor, ctor );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
err = tr_torrentParse( ctor, &tmpInfo );
|
||||
const int err = tr_torrentParse( ctor, &tmpInfo );
|
||||
if( !err )
|
||||
{
|
||||
tor = tr_new0( tr_torrent, 1 );
|
||||
|
|
Loading…
Reference in a new issue