[packages] transmission: make scrape-paused-torrents optional
authorCezary Jackiewicz <cezary@eko.one.pl>
Fri, 27 May 2011 18:55:37 +0000 (18:55 +0000)
committerCezary Jackiewicz <cezary@eko.one.pl>
Fri, 27 May 2011 18:55:37 +0000 (18:55 +0000)
SVN-Revision: 27020

net/transmission/Makefile
net/transmission/files/transmission.config
net/transmission/files/transmission.init
net/transmission/patches/010-opt_scrape_paused.patch [new file with mode: 0644]

index ab96afe55ead49ac077f1913079b6e1f8b7637ee..b58c58a7ea2a8aa6d2b43d80ea4f917dbf18e6a6 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=transmission
 PKG_VERSION:=2.31
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=http://mirrors.m0k.org/transmission/files
index c69ebc95ae9317c4d6dd2fe6e8df2ff8d0271c98..8e3db7bfcdbffc9b2698533c5f5f39c5d1906523 100644 (file)
@@ -60,5 +60,6 @@ config transmission
        option umask 18
        option upload_slots_per_torrent 14
        option utp_enabled true
+       option scrape_paused_torrents true
        option watch_dir_enabled false
        option watch_dir ''
index 1c77d949b839f735faf19aea7d2afc6c4a643243..bb5e52ae9268811926bf7f9697c2df599761cf9d 100644 (file)
@@ -65,7 +65,8 @@ start_service() {
                rpc_enabled rpc_port rpc_whitelist_enabled script_torrent_done_enabled \
                speed_limit_down speed_limit_down_enabled speed_limit_up \
                speed_limit_up_enabled start_added_torrents trash_original_torrent_files \
-               umask upload_slots_per_torrent utp_enabled watch_dir_enabled
+               umask upload_slots_per_torrent utp_enabled scrape_paused_torrents \
+               watch_dir_enabled
 
        append_params_quotes "$s" \
                blocklist_url bind_address_ipv4 bind_address_ipv6 download_dir incomplete_dir \
diff --git a/net/transmission/patches/010-opt_scrape_paused.patch b/net/transmission/patches/010-opt_scrape_paused.patch
new file mode 100644 (file)
index 0000000..266a305
--- /dev/null
@@ -0,0 +1,131 @@
+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 * );