Changeset 12577


Ignore:
Timestamp:
Jul 23, 2011, 5:14:12 PM (10 years ago)
Author:
jordan
Message:

(trunk libT) #3219 "Don't scrape paused torrents" -- allow this as a 'hidden' option in settings.json, but don't add it to the GUI or to RPC.

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/announcer.c

    r12517 r12577  
    314314
    315315static time_t
    316 get_next_scrape_time( int interval )
     316get_next_scrape_time( const tr_session * session, const tr_tier * tier, int interval )
    317317{
    318318    time_t ret;
    319319    const time_t now = tr_time( );
     320
     321    /* Maybe don't scrape paused torrents */
     322    if( !tier->isRunning && !session->scrapePausedTorrents )
     323        ret = 0;
    320324
    321325    /* Add the interval, and then increment to the nearest 10th second.
    322326     * The latter step is to increase the odds of several torrents coming
    323327     * due at the same time to improve multiscrape. */
    324     ret = now + interval;
    325     while( ret % 10 ) ++ret;
     328    else {
     329        ret = now + interval;
     330        while( ret % 10 )
     331            ++ret;
     332    }
     333
    326334    return ret;
    327335}
     
    339347    tier->announceIntervalSec = DEFAULT_ANNOUNCE_INTERVAL_SEC;
    340348    tier->announceMinIntervalSec = DEFAULT_ANNOUNCE_MIN_INTERVAL_SEC;
    341     tier->scrapeAt = get_next_scrape_time( tr_cryptoWeakRandInt( 180 ) );
     349    tier->scrapeAt = get_next_scrape_time( tor->session, tier, tr_cryptoWeakRandInt( 180 ) );
    342350    tier->tor = tor;
    343351}
     
    11101118
    11111119            tier->isRunning = data->isRunningOnSuccess;
    1112             tier->scrapeAt = get_next_scrape_time( tier->scrapeIntervalSec );
     1120            tier->scrapeAt = get_next_scrape_time( announcer->session, tier, tier->scrapeIntervalSec );
    11131121            tier->lastScrapeTime = now;
    11141122            tier->lastScrapeSucceeded = true;
     
    12021210
    12031211static void
    1204 on_scrape_error( tr_tier * tier, const char * errmsg )
     1212on_scrape_error( tr_session * session, tr_tier * tier, const char * errmsg )
    12051213{
    12061214    int interval;
     
    12231231    tr_torinf( tier->tor, "Retrying scrape in %zu seconds.", (size_t)interval );
    12241232    tier->lastScrapeSucceeded = false;
    1225     tier->scrapeAt = get_next_scrape_time( interval );
     1233    tier->scrapeAt = get_next_scrape_time( session, tier, interval );
    12261234}
    12271235
     
    12861294                if( !response->did_connect )
    12871295                {
    1288                     on_scrape_error( tier, _( "Could not connect to tracker" ) );
     1296                    on_scrape_error( session, tier, _( "Could not connect to tracker" ) );
    12891297                }
    12901298                else if( response->did_timeout )
    12911299                {
    1292                     on_scrape_error( tier, _( "Tracker did not respond" ) );
     1300                    on_scrape_error( session, tier, _( "Tracker did not respond" ) );
    12931301                }
    12941302                else if( response->errmsg )
    12951303                {
    1296                     on_scrape_error( tier, response->errmsg );
     1304                    on_scrape_error( session, tier, response->errmsg );
    12971305                }
    12981306                else
     
    13031311                    tier->scrapeIntervalSec = MAX( DEFAULT_SCRAPE_INTERVAL_SEC,
    13041312                                                   response->min_request_interval );
    1305                     tier->scrapeAt = get_next_scrape_time( tier->scrapeIntervalSec );
     1313                    tier->scrapeAt = get_next_scrape_time( session, tier, tier->scrapeIntervalSec );
    13061314                    tr_tordbg( tier->tor, "Scrape successful. Rescraping in %d seconds.",
    13071315                               tier->scrapeIntervalSec );
  • trunk/libtransmission/session.c

    r12545 r12577  
    343343    tr_bencDictAddInt ( d, TR_PREFS_KEY_RPC_PORT,                 atoi( TR_DEFAULT_RPC_PORT_STR ) );
    344344    tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_URL,                  TR_DEFAULT_RPC_URL_STR );
     345    tr_bencDictAddBool( d, TR_PREFS_KEY_SCRAPE_PAUSED_TORRENTS,   true );
    345346    tr_bencDictAddStr ( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, "" );
    346347    tr_bencDictAddBool( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED, false );
     
    407408    tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_WHITELIST,            tr_sessionGetRPCWhitelist( s ) );
    408409    tr_bencDictAddBool( d, TR_PREFS_KEY_RPC_WHITELIST_ENABLED,    tr_sessionGetRPCWhitelistEnabled( s ) );
     410    tr_bencDictAddBool( d, TR_PREFS_KEY_SCRAPE_PAUSED_TORRENTS,   s->scrapePausedTorrents );
    409411    tr_bencDictAddBool( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED, tr_sessionIsTorrentDoneScriptEnabled( s ) );
    410412    tr_bencDictAddStr ( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, tr_sessionGetTorrentDoneScript( s ) );
     
    887889        tr_sessionSetTorrentDoneScript( session, str );
    888890
     891
     892    if( tr_bencDictFindBool( settings, TR_PREFS_KEY_SCRAPE_PAUSED_TORRENTS, &boolVal ) )
     893        session->scrapePausedTorrents = boolVal;
     894
    889895    data->done = true;
    890896}
  • trunk/libtransmission/session.h

    r12514 r12577  
    108108    bool                         pauseAddedTorrent;
    109109    bool                         deleteSourceTorrent;
     110    bool                         scrapePausedTorrents;
    110111
    111112    tr_benc                      removedTorrents;
  • trunk/libtransmission/transmission.h

    r12514 r12577  
    202202#define TR_PREFS_KEY_RPC_URL                      "rpc-url"
    203203#define TR_PREFS_KEY_RPC_WHITELIST_ENABLED        "rpc-whitelist-enabled"
     204#define TR_PREFS_KEY_SCRAPE_PAUSED_TORRENTS       "scrape-paused-torrents-enabled"
    204205#define TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME "script-torrent-done-filename"
    205206#define TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED  "script-torrent-done-enabled"
Note: See TracChangeset for help on using the changeset viewer.