Changeset 9557


Ignore:
Timestamp:
Nov 24, 2009, 5:31:20 PM (13 years ago)
Author:
charles
Message:

(trunk libT) don't allow duplicate torrents to be added via magnet links

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-msgs.c

    r9553 r9557  
    18731873            tr_bencDictAddInt( &tmp, "msg_type", METADATA_MSG_TYPE_DATA );
    18741874            tr_bencDictAddInt( &tmp, "piece", piece );
    1875             tr_bencDictAddInt( &tmp, "total_size", dataLen );
     1875            tr_bencDictAddInt( &tmp, "total_size", msgs->torrent->infoDictLength );
    18761876            payload = tr_bencToStr( &tmp, TR_FMT_BENC, &payloadLen );
    18771877            tr_bencFree( &tmp );
  • trunk/libtransmission/torrent.c

    r9556 r9557  
    768768               int            * setmeError )
    769769{
    770     int err;
    771770    tr_info tmpInfo;
    772771    tr_torrent * tor = NULL;
    773772    const tr_magnet_info * magnetInfo;
     773    tr_session * session = tr_ctorGetSession( ctor );
    774774
    775775    assert( ctor != NULL );
    776     assert( tr_isSession( tr_ctorGetSession( ctor ) ) );
     776    assert( tr_isSession( session ) );
    777777
    778778    if( !tr_ctorGetMagnet( ctor, &magnetInfo ) )
    779779    {
    780         tor = tr_new0( tr_torrent, 1 );
    781         tr_metainfoSetFromMagnet( &tor->info, magnetInfo );
    782         torrentInit( tor, ctor );
     780        if( tr_torrentFindFromHash( session, magnetInfo->hash ) != NULL )
     781        {
     782            if( setmeError )
     783                *setmeError = TR_PARSE_DUPLICATE;
     784        }
     785        else
     786        {
     787            tor = tr_new0( tr_torrent, 1 );
     788            tr_metainfoSetFromMagnet( &tor->info, magnetInfo );
     789            torrentInit( tor, ctor );
     790        }
    783791    }
    784792    else
    785793    {
    786         err = tr_torrentParse( ctor, &tmpInfo );
     794        const int err = tr_torrentParse( ctor, &tmpInfo );
    787795        if( !err )
    788796        {
Note: See TracChangeset for help on using the changeset viewer.