Ticket #1772: transmission-mark_done.diff

File transmission-mark_done.diff, 1.1 KB (added by turbo, 12 years ago)

Get a list of all 'Done' torrents

  • libtransmission/rpcimpl.c

    diff -ur transmission-SVN.old/libtransmission/rpcimpl.c transmission-SVN/libtransmission/rpcimpl.c
    old new  
    124124{
    125125    int           torrentCount = 0;
    126126    int64_t       id;
     127    char *        id_str;
    127128    tr_torrent ** torrents = NULL;
    128129    tr_benc *     ids;
    129130
     
    155156        if( ( tor = tr_torrentFindFromId( session, id ) ) )
    156157            torrents[torrentCount++] = tor;
    157158    }
     159    else if( tr_bencDictFindStr( args, "ids", &id_str )
     160             && (strncmp( id_str, "done", 4 ) == 0))
     161    {
     162        tr_torrent *    tor = NULL;
     163        const int       n   = tr_sessionCountTorrents( session );
     164        const tr_stat * st;
     165
     166        torrents = tr_new0( tr_torrent *, n );
     167        while( ( tor = tr_torrentNext( session, tor ) ) ) {
     168            st  = tr_torrentStat( (tr_torrent*)tor );
     169            if( st->eta == TR_ETA_UNKNOWN && st->leftUntilDone == 0 )
     170              torrents[torrentCount++] = tor;
     171        }
     172    }
    158173    else /* all of them */
    159174    {
    160175        tr_torrent * tor = NULL;