From 6ce1b72434b255c410be4b0b3d33bd7d122ac75d Mon Sep 17 00:00:00 2001 From: Cezary Jackiewicz Date: Fri, 27 May 2011 18:55:37 +0000 Subject: [PATCH] [packages] transmission: make scrape-paused-torrents optional SVN-Revision: 27020 --- net/transmission/Makefile | 2 +- net/transmission/files/transmission.config | 1 + net/transmission/files/transmission.init | 3 +- .../patches/010-opt_scrape_paused.patch | 131 ++++++++++++++++++ 4 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 net/transmission/patches/010-opt_scrape_paused.patch diff --git a/net/transmission/Makefile b/net/transmission/Makefile index ab96afe55e..b58c58a7ea 100644 --- a/net/transmission/Makefile +++ b/net/transmission/Makefile @@ -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 diff --git a/net/transmission/files/transmission.config b/net/transmission/files/transmission.config index c69ebc95ae..8e3db7bfcd 100644 --- a/net/transmission/files/transmission.config +++ b/net/transmission/files/transmission.config @@ -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 '' diff --git a/net/transmission/files/transmission.init b/net/transmission/files/transmission.init index 1c77d949b8..bb5e52ae92 100644 --- a/net/transmission/files/transmission.init +++ b/net/transmission/files/transmission.init @@ -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 index 0000000000..266a305e06 --- /dev/null +++ b/net/transmission/patches/010-opt_scrape_paused.patch @@ -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 && itier_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; itier_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 * ); + -- 2.30.2