packages/net/transmission/patches/010-opt_scrape_paused.patch
obsy d1bb58c28b [packages] transmission: make scrape-paused-torrents optional
git-svn-id: svn://svn.openwrt.org/openwrt/packages@27020 3c298f89-4303-0410-b956-a3cf2f4a3e73
2011-05-27 18:55:37 +00:00

132 lines
5.7 KiB
Diff

Index: transmission-2.31/libtransmission/announcer.c
===================================================================
--- transmission-2.31.orig/libtransmission/announcer.c 2011-05-23 13:34:54.000000000 +0200
+++ transmission-2.31/libtransmission/announcer.c 2011-05-23 13:48:03.000000000 +0200
@@ -1433,11 +1433,13 @@
tor = NULL;
while(( tor = tr_torrentNext( announcer->session, tor ))) {
struct tr_torrent_tiers * tt = tor->tiers;
+ const bool paused = !tor->isRunning;
+ const bool scrapePaused = tr_sessionGetScrapePaused( announcer->session );
for( i=0; tt && i<tt->tier_count; ++i ) {
tr_tier * tier = &tt->tiers[i];
if( tierNeedsToAnnounce( tier, now ) )
tr_ptrArrayAppend( &announceMe, tier );
- else if( tierNeedsToScrape( tier, now ) )
+ else if( tierNeedsToScrape( tier, now ) && ( !paused || scrapePaused ) )
tr_ptrArrayAppend( &scrapeMe, tier );
}
}
@@ -1505,6 +1507,7 @@
tr_tracker_stat * ret;
struct tr_torrent_tiers * tt;
const time_t now = tr_time( );
+ bool scrapePaused;
assert( tr_isTorrent( torrent ) );
assert( tr_torrentIsLocked( torrent ) );
@@ -1515,6 +1518,8 @@
*setmeTrackerCount = tt->tracker_count;
ret = tr_new0( tr_tracker_stat, tt->tracker_count );
+ scrapePaused = tr_sessionGetScrapePaused( torrent->session );
+
/* populate the stats */
for( i=0; i<tt->tier_count; ++i )
{
@@ -1559,7 +1564,7 @@
if( tier->isScraping )
st->scrapeState = TR_TRACKER_ACTIVE;
- else if( !tier->scrapeAt )
+ else if( !tier->scrapeAt || ( !torrent->isRunning && !scrapePaused ) )
st->scrapeState = TR_TRACKER_INACTIVE;
else if( tier->scrapeAt > now )
{
Index: transmission-2.31/libtransmission/session.c
===================================================================
--- transmission-2.31.orig/libtransmission/session.c 2011-05-23 13:41:05.000000000 +0200
+++ transmission-2.31/libtransmission/session.c 2011-05-23 13:50:23.000000000 +0200
@@ -359,6 +359,7 @@
tr_bencDictAddStr ( d, TR_PREFS_KEY_BIND_ADDRESS_IPV4, TR_DEFAULT_BIND_ADDRESS_IPV4 );
tr_bencDictAddStr ( d, TR_PREFS_KEY_BIND_ADDRESS_IPV6, TR_DEFAULT_BIND_ADDRESS_IPV6 );
tr_bencDictAddBool( d, TR_PREFS_KEY_START, true );
+ tr_bencDictAddBool( d, TR_PREFS_KEY_SCRAPE_PAUSED_TORRENTS, true );
tr_bencDictAddBool( d, TR_PREFS_KEY_TRASH_ORIGINAL, false );
}
@@ -424,6 +425,7 @@
tr_bencDictAddStr ( d, TR_PREFS_KEY_BIND_ADDRESS_IPV4, tr_address_to_string( &s->public_ipv4->addr ) );
tr_bencDictAddStr ( d, TR_PREFS_KEY_BIND_ADDRESS_IPV6, tr_address_to_string( &s->public_ipv6->addr ) );
tr_bencDictAddBool( d, TR_PREFS_KEY_START, !tr_sessionGetPaused( s ) );
+ tr_bencDictAddBool( d, TR_PREFS_KEY_SCRAPE_PAUSED_TORRENTS, tr_sessionGetScrapePaused( s ) );
tr_bencDictAddBool( d, TR_PREFS_KEY_TRASH_ORIGINAL, tr_sessionGetDeleteSource( s ) );
}
@@ -776,6 +778,8 @@
tr_blocklistSetURL( session, str );
if( tr_bencDictFindBool( settings, TR_PREFS_KEY_START, &boolVal ) )
tr_sessionSetPaused( session, !boolVal );
+ if( tr_bencDictFindBool( settings, TR_PREFS_KEY_SCRAPE_PAUSED_TORRENTS, &boolVal ) )
+ tr_sessionSetScrapePaused( session, boolVal );
if( tr_bencDictFindBool( settings, TR_PREFS_KEY_TRASH_ORIGINAL, &boolVal) )
tr_sessionSetDeleteSource( session, boolVal );
@@ -1636,6 +1640,22 @@
}
void
+tr_sessionSetScrapePaused( tr_session * session, bool enable )
+{
+ assert( tr_isSession( session ) );
+
+ session->scrapePausedTorrents = enable;
+}
+
+bool
+tr_sessionGetScrapePaused( const tr_session * session )
+{
+ assert( tr_isSession( session ) );
+
+ return session->scrapePausedTorrents;
+}
+
+void
tr_sessionSetDeleteSource( tr_session * session, bool deleteSource )
{
assert( tr_isSession( session ) );
Index: transmission-2.31/libtransmission/session.h
===================================================================
--- transmission-2.31.orig/libtransmission/session.h 2011-05-23 13:45:30.000000000 +0200
+++ transmission-2.31/libtransmission/session.h 2011-05-23 13:46:12.000000000 +0200
@@ -106,6 +106,7 @@
bool isIdleLimited;
bool isIncompleteDirEnabled;
bool pauseAddedTorrent;
+ bool scrapePausedTorrents;
bool deleteSourceTorrent;
tr_benc removedTorrents;
Index: transmission-2.31/libtransmission/transmission.h
===================================================================
--- transmission-2.31.orig/libtransmission/transmission.h 2011-05-23 13:48:11.000000000 +0200
+++ transmission-2.31/libtransmission/transmission.h 2011-05-23 13:49:15.000000000 +0200
@@ -213,6 +213,7 @@
#define TR_PREFS_KEY_UMASK "umask"
#define TR_PREFS_KEY_UPLOAD_SLOTS_PER_TORRENT "upload-slots-per-torrent"
#define TR_PREFS_KEY_START "start-added-torrents"
+#define TR_PREFS_KEY_SCRAPE_PAUSED_TORRENTS "scrape-paused-torrents"
#define TR_PREFS_KEY_TRASH_ORIGINAL "trash-original-torrent-files"
@@ -731,6 +732,9 @@
void tr_sessionSetPaused ( tr_session *, bool isPaused );
bool tr_sessionGetPaused ( const tr_session * );
+void tr_sessionSetScrapePaused ( tr_session *, bool enable );
+bool tr_sessionGetScrapePaused ( const tr_session * );
+
void tr_sessionSetDeleteSource ( tr_session *, bool deleteSource );
bool tr_sessionGetDeleteSource ( const tr_session * );