]> granicus.if.org Git - transmission/commitdiff
(libT) #319: periodically save the .resume file in case of crash
authorCharles Kerr <charles@transmissionbt.com>
Wed, 2 Jul 2008 01:46:10 +0000 (01:46 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Wed, 2 Jul 2008 01:46:10 +0000 (01:46 +0000)
libtransmission/resume.c
libtransmission/tracker.c

index db98b95ee3b1c247c258bca134151c8d1d127b4e..d399b5792d8350599045762d55624b62bad0fc5a 100644 (file)
@@ -350,6 +350,9 @@ tr_torrentSaveResume( const tr_torrent * tor )
     tr_benc top;
     char filename[MAX_PATH_LENGTH];
 
+    if( !tor )
+        return;
+
     tr_bencInitDict( &top, 14 );
     tr_bencDictAddInt( &top, KEY_ACTIVITY_DATE,
                              tor->activityDate );
index f97dee007dcce52ebd0d142cc0014d5aab06c9d0..c0388ce5c1af6dd12f45e2919949eee646194f5c 100644 (file)
@@ -22,6 +22,7 @@
 #include "completion.h"
 #include "net.h"
 #include "publish.h"
+#include "resume.h"
 #include "torrent.h"
 #include "tracker.h"
 #include "trevent.h"
@@ -400,6 +401,10 @@ onTrackerResponse( tr_session    * session,
         t->scrapeAt = now + t->scrapeIntervalSec + t->randOffset;
         t->reannounceAt = now + interval;
         t->manualAnnounceAllowedAt = now + t->announceMinIntervalSec;
+
+        /* #319: save the .resume file after an announce so that, in case
+         * of a crash, our stats still match up with the tracker's stats */
+        tr_torrentSaveResume( tr_torrentFindFromHash( t->session, t->hash ) );
     }
     else if( 300<=responseCode && responseCode<=399 )
     {