From c8d339c9eec7a87e557a66ad7c87ea0e421f8a98 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 2 Jul 2008 01:46:10 +0000 Subject: [PATCH] (libT) #319: periodically save the .resume file in case of crash --- libtransmission/resume.c | 3 +++ libtransmission/tracker.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/libtransmission/resume.c b/libtransmission/resume.c index db98b95ee..d399b5792 100644 --- a/libtransmission/resume.c +++ b/libtransmission/resume.c @@ -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 ); diff --git a/libtransmission/tracker.c b/libtransmission/tracker.c index f97dee007..c0388ce5c 100644 --- a/libtransmission/tracker.c +++ b/libtransmission/tracker.c @@ -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 ) { -- 2.40.0