diff --git a/libtransmission/session.c b/libtransmission/session.c index 6d0caf569..9e419ef27 100644 --- a/libtransmission/session.c +++ b/libtransmission/session.c @@ -1881,7 +1881,7 @@ tr_sessionLoadTorrents( tr_session * session, tr_ctorSetMetainfoFromFile( ctor, path ); if(( tor = tr_torrentNew( ctor, NULL ))) { - tr_list_append( &list, tor ); + tr_list_prepend( &list, tor ); ++n; } tr_free( path ); diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index 633a82360..72572a9ae 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -869,17 +869,14 @@ torrentInit( tr_torrent * tor, const tr_ctor * ctor ) } /* add the torrent to tr_session.torrentList */ - { - tr_torrent * it = NULL; - tr_torrent * last = NULL; - while(( it = tr_torrentNext( session, it ))) - last = it; - - if( !last ) - session->torrentList = tor; - else - last->next = tor; - ++session->torrentCount; + ++session->torrentCount; + if( session->torrentList == NULL ) + session->torrentList = tor; + else { + tr_torrent * it = session->torrentList; + while( it->next != NULL ) + it = it->next; + it->next = tor; } /* if we don't have a local .torrent file already, assume the torrent is new */