(trunk rpc) added "recently-active" as a valid "ids" argument in torrent-get, etc.
This commit is contained in:
parent
63f023f71c
commit
5cd6c41ec7
|
@ -79,10 +79,12 @@
|
|||
"torrent-stop" | tr_torrentStop
|
||||
"torrent-verify" | tr_torrentVerify
|
||||
|
||||
Request arguments: "ids", a list of torrent id numbers, sha1 hash strings,
|
||||
or both. These are the torrents that the request will
|
||||
be applied to. If "ids" is ommitted, the request is
|
||||
applied to all torrents.
|
||||
Request arguments: "ids", which specifies which torrents to use.
|
||||
All torrents are used if the "ids" argument is omitted.
|
||||
"ids" should be one of the following:
|
||||
(1) an integer referring to a torrent id
|
||||
(2) a list of torrent id numbers, sha1 hash strings, or both
|
||||
(3) a string, "recently-active", for recently-active torrents
|
||||
|
||||
Response arguments: none
|
||||
|
||||
|
@ -432,6 +434,7 @@
|
|||
| | yes | torrent-get | new arg "speed-limit-up"
|
||||
| | yes | torrent-get | new arg "speed-limit-up-enabled"
|
||||
| | yes | torrent-get | new arg "speed-limit-up-global-enabled"
|
||||
| | yes | torrent-get | new ids option "recently-active"
|
||||
| | NO | torrent-get | removed arg "downloadLimit"
|
||||
| | NO | torrent-get | removed arg "downloadLimitMode"
|
||||
| | NO | torrent-get | removed arg "uploadLimit"
|
||||
|
|
|
@ -111,6 +111,7 @@ getTorrents( tr_session * session,
|
|||
int64_t id;
|
||||
tr_torrent ** torrents = NULL;
|
||||
tr_benc * ids;
|
||||
const char * str;
|
||||
|
||||
if( tr_bencDictFindList( args, "ids", &ids ) )
|
||||
{
|
||||
|
@ -140,6 +141,25 @@ getTorrents( tr_session * session,
|
|||
if( ( tor = tr_torrentFindFromId( session, id ) ) )
|
||||
torrents[torrentCount++] = tor;
|
||||
}
|
||||
else if( tr_bencDictFindStr( args, "ids", &str ) )
|
||||
{
|
||||
if( !strcmp( str, "recently-active" ) )
|
||||
{
|
||||
tr_torrent * tor = NULL;
|
||||
const time_t now = time( NULL );
|
||||
const time_t window = 120;
|
||||
const int n = tr_sessionCountTorrents( session );
|
||||
torrents = tr_new0( tr_torrent *, n );
|
||||
while( ( tor = tr_torrentNext( session, tor ) ) ) {
|
||||
time_t a = tor->activityDate;
|
||||
a = MAX( a, tor->addedDate );
|
||||
a = MAX( a, tor->doneDate );
|
||||
a = MAX( a, tor->startDate );
|
||||
if( a >= now - window )
|
||||
torrents[torrentCount++] = tor;
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* all of them */
|
||||
{
|
||||
tr_torrent * tor = NULL;
|
||||
|
|
Loading…
Reference in New Issue