(trunk libT) fix #1765: "if a downloaded file disappears, stop the torrent instead of redownloading it"

This commit is contained in:
Charles Kerr 2009-08-13 17:50:41 +00:00
parent 3dbf1aef96
commit deb25906d0
2 changed files with 24 additions and 12 deletions

View File

@ -1259,24 +1259,33 @@ freeTorrent( tr_torrent * tor )
static void
checkAndStartImpl( void * vtor )
{
time_t now;
tr_torrent * tor = vtor;
assert( tr_isTorrent( tor ) );
tr_globalLock( tor->session );
now = time( NULL );
tor->isRunning = TRUE;
tor->needsSeedRatioCheck = TRUE;
tor->error = TR_STAT_OK;
tor->errorString[0] = '\0';
tor->completeness = tr_cpGetStatus( &tor->completion );
tor->startDate = tor->anyDate = now;
tr_torrentResetTransferStats( tor );
tr_trackerStart( tor->tracker );
tor->dhtAnnounceAt = now + tr_cryptoWeakRandInt( 20 );
tr_peerMgrStartTorrent( tor );
/** If we had local data before, but it's disappeared,
stop the torrent and log an error. */
if( tor->preVerifyTotal && !tr_cpHaveTotal( &tor->completion ) )
{
tr_torrentSetLocalError( tor, "Can't find local data. Try \"Set Location\" to find it, or restart the torrent to re-download." );
tr_torrentStop( tor );
}
else
{
const time_t now = time( NULL );
tor->isRunning = TRUE;
tor->needsSeedRatioCheck = TRUE;
tor->error = TR_STAT_OK;
tor->errorString[0] = '\0';
tor->completeness = tr_cpGetStatus( &tor->completion );
tor->startDate = tor->anyDate = now;
tr_torrentResetTransferStats( tor );
tr_trackerStart( tor->tracker );
tor->dhtAnnounceAt = now + tr_cryptoWeakRandInt( 20 );
tr_peerMgrStartTorrent( tor );
}
tr_globalUnlock( tor->session );
}
@ -1301,6 +1310,7 @@ torrentStart( tr_torrent * tor )
{
tr_verifyRemove( tor );
tor->isRunning = 1;
tor->preVerifyTotal = tr_cpHaveTotal( &tor->completion );
tr_verifyAdd( tor, checkAndStartCB );
}

View File

@ -228,6 +228,8 @@ struct tr_torrent
double desiredRatio;
tr_ratiolimit ratioLimitMode;
uint64_t preVerifyTotal;
};
/* get the index of this piece's first block */