]> granicus.if.org Git - transmission/commitdiff
(trunk libT) #4237 "tarnsmission-remote -l shows torrent list in reverse order" ...
authorJordan Lee <jordan@transmissionbt.com>
Mon, 16 May 2011 02:09:31 +0000 (02:09 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Mon, 16 May 2011 02:09:31 +0000 (02:09 +0000)
libtransmission/torrent.c

index 825c6e92f01c98257e7d33eb56e11cae1e26ca1c..633a823607e04c01639faed205d618be5d56cb51 100644 (file)
@@ -869,9 +869,18 @@ torrentInit( tr_torrent * tor, const tr_ctor * ctor )
     }
 
     /* add the torrent to tr_session.torrentList */
-    tor->next = session->torrentList;
-    session->torrentList = tor;
-    ++session->torrentCount;
+    {
+        tr_torrent * it = NULL;
+        tr_torrent * last = NULL;
+        while(( it = tr_torrentNext( session, it )))
+            last = it;
+
+        if( !last )
+            session->torrentList = tor;
+        else
+            last->next = tor;
+        ++session->torrentCount;
+    }
 
     /* if we don't have a local .torrent file already, assume the torrent is new */
     isNewTorrent = stat( tor->info.torrent, &st );