Changeset 3810


Ignore:
Timestamp:
Nov 12, 2007, 3:15:51 PM (14 years ago)
Author:
charles
Message:

tiennou's fix for #461

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEWS

    r3809 r3810  
    55   + UPnP now performed by MiniUPnP
    66   + Option to prefer not using encryption
     7   + Restore `scrape' feature in the command-line interface client
    78- OS X:
    89   + Leopard: Time Machine will ignore incomplete downloads
  • trunk/cli/transmissioncli.c

    r3486 r3810  
    3232#include <libtransmission/transmission.h>
    3333#include <libtransmission/makemeta.h>
    34 
    35 #ifdef __BEOS__
    36     #include <kernel/OS.h>
    37     #define wait_msecs(N)  snooze( (N) * 1000 )
    38     #define wait_secs(N)   sleep( (N) )
    39 #elif defined(WIN32)
    40     #include <windows.h>
    41     #define wait_msecs(N)  Sleep( (N) )
    42     #define wait_secs(N)   Sleep( (N) * 1000 )
    43 #else
    44     #define wait_msecs(N)  usleep( (N) * 1000 )
    45     #define wait_secs(N)   sleep( (N) )
    46 #endif
     34#include <libtransmission/utils.h> /* tr_wait */
    4735
    4836/* macro to shut up "unused parameter" warnings */
     
    6654"  -n  --nat-traversal  Attempt NAT traversal using NAT-PMP or UPnP IGD\n"
    6755"  -p, --port <int>     Port we should listen on (default = %d)\n"
    68 #if 0
    6956"  -s, --scrape         Print counts of seeders/leechers and exit\n"
    70 #endif
    7157"  -u, --upload <int>   Maximum upload rate (-1 = no limit, default = 20)\n"
    7258"  -v, --verbose <int>  Verbose level (0 to 2, default = 0)\n";
     
    7460static int           showHelp      = 0;
    7561static int           showInfo      = 0;
    76 #if 0
    7762static int           showScrape    = 0;
    78 #endif
    7963static int           isPrivate     = 0;
    8064static int           verboseLevel  = 0;
     
    169153        tr_makeMetaInfo( builder, torrentPath, announce, comment, isPrivate );
    170154        while( !builder->isDone ) {
    171             wait_msecs( 1 );
     155            tr_wait( 1000 );
    172156            printf( "." );
    173157        }
     
    225209        goto cleanup;
    226210    }
    227 
    228 #if 0
     211   
    229212    if( showScrape )
    230213    {
    231         int seeders, leechers, downloaded;
    232 
    233         if( tr_torrentScrape( tor, &seeders, &leechers, &downloaded ) )
    234         {
    235             printf( "Scrape failed.\n" );
    236         }
    237         else
    238         {
    239             printf( "%d seeder(s), %d leecher(s), %d download(s).\n",
    240                     seeders, leechers, downloaded );
    241         }
     214        printf( "Scraping, Please wait...\n" );
     215        const tr_stat * stats;
     216       
     217        uint64_t start = tr_date();
     218       
     219        do
     220        {
     221            stats = tr_torrentStat( tor );
     222            if( stats == NULL || tr_date() - start > 20000 )
     223            {
     224                printf( "Scrape failed.\n" );
     225                goto cleanup;
     226            }
     227            tr_wait( 2000 );
     228        }
     229        while( stats->completedFromTracker == -1 || stats->leechers == -1 || stats->seeders == -1 );
     230       
     231        printf( "%d seeder(s), %d leecher(s), %d download(s).\n",
     232            stats->seeders, stats->leechers, stats->completedFromTracker );
    242233
    243234        goto cleanup;
    244235    }
    245 #endif
    246236
    247237    signal( SIGINT, sigHandler );
     
    265255        int  chars = 0;
    266256
    267         wait_secs( 1 );
     257        tr_wait( 1000 );
    268258
    269259        if( gotsig )
     
    290280        {
    291281            chars = snprintf( string, sizeof string,
    292                 "Waiting to verify local files... %.2f %%", 100.0 * s->percentDone );
     282                "Waiting to verify local files..." );
    293283        }
    294284        else if( s->status & TR_STATUS_CHECK )
    295285        {
    296286            chars = snprintf( string, sizeof string,
    297                 "Verifying local files... %.2f %%", 100.0 * s->percentDone );
     287                "Verifying local files... %.2f%%, found %.2f%% valid", 100 * s->recheckProgress, 100.0 * s->percentDone );
    298288        }
    299289        else if( s->status & TR_STATUS_DOWNLOAD )
     
    346336            break;
    347337        }
    348         wait_msecs( 500 );
     338        tr_wait( 500 );
    349339    }
    350340   
     
    391381                showInfo = 1;
    392382                break;
    393 #if 0
    394383            case 's':
    395384                showScrape = 1;
    396385                break;
    397 #endif
    398386            case 'r':
    399387                isPrivate = 1;
  • trunk/libtransmission/transmission.h

    r3759 r3810  
    412412const tr_info * tr_torrentInfo( const tr_torrent * );
    413413
    414 #if 0
    415 /***********************************************************************
    416  * tr_torrentScrape
    417  ***********************************************************************
    418  * Asks the tracker for the count of seeders and leechers. Returns 0
    419  * and fills 's' and 'l' if successful. Otherwise returns 1 if the
    420  * tracker doesn't support the scrape protocol, is unreachable or
    421  * replied with some error. tr_torrentScrape may block up to 20 seconds
    422  * before returning.
    423  **********************************************************************/
    424 int tr_torrentScrape( tr_torrent *, int * s, int * l, int * d );
    425 #endif
    426 
    427414void   tr_torrentSetFolder( tr_torrent *, const char * );
    428415const char * tr_torrentGetFolder( const tr_torrent * );
Note: See TracChangeset for help on using the changeset viewer.