From cd00ad4f559f42aadac9d8b7787c7f4f952841fb Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Sun, 20 Oct 2013 17:24:57 +0000 Subject: [PATCH] (trunk, libT) #5450: when starting torrents via RPC with torrent-start or torrent-start-now requests, work through the rpc-supplied torrent list in queue order --- libtransmission/rpcimpl.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libtransmission/rpcimpl.c b/libtransmission/rpcimpl.c index 85d8951d3..79ac378ff 100644 --- a/libtransmission/rpcimpl.c +++ b/libtransmission/rpcimpl.c @@ -253,6 +253,15 @@ queueMoveBottom (tr_session * session, return NULL; } +static int +compareTorrentByQueuePosition (const void * va, const void * vb) +{ + const tr_torrent * a = * (const tr_torrent **) va; + const tr_torrent * b = * (const tr_torrent **) vb; + + return a->queuePosition - b->queuePosition; +} + static const char* torrentStart (tr_session * session, tr_variant * args_in, @@ -266,6 +275,7 @@ torrentStart (tr_session * session, assert (idle_data == NULL); torrents = getTorrents (session, args_in, &torrentCount); + qsort (torrents, torrentCount, sizeof (tr_torrent *), compareTorrentByQueuePosition); for (i=0; i