(trunk libT) #2955 "verify pieces only when necessary, or when the user requests it." -- add better support for old .resume files

Super-poussin says some readynas users are reporting high CPU oloads in 2.20 beta 1. My guess is this is due to pieces being reverified. Before now, the .resume files kept timestamps per-file, and 2.20 keeps timestamps per-piece. The problem is that 2.20 beta 1 didn't support reading the older per-file timetstamps from .resume files, so users loading up 2.20 beta 1 may find Transmission thinks none of the pieces in the torrents have been verified.

The fix is to have 2.20 beta 2 read the old per-file timestamps, so upgrading from 2.1x to 2.20 will go smoothly. That's what this commit does.

Unfortunately, the readynas users who have already been bitten by this will continue to be bitten until they reverify their files. 2.20 beta 1, which thinks all those pieces were never verified, has probably overwritten the .resume files from 2.1x... :(
This commit is contained in:
Jordan Lee 2011-01-24 05:11:16 +00:00
parent 6de2ac3e4b
commit 4e38d97621
1 changed files with 34 additions and 1 deletions

View File

@ -63,6 +63,7 @@
#define KEY_IDLELIMIT_MODE "idle-mode"
#define KEY_PROGRESS_CHECKTIME "time-checked"
#define KEY_PROGRESS_MTIMES "mtimes"
#define KEY_PROGRESS_BITFIELD "bitfield"
#define KEY_PROGRESS_HAVE "have"
@ -451,11 +452,43 @@ loadProgress( tr_benc * dict,
tr_benc * m;
int64_t timeChecked;
/* load in the timestamp of when we last checked each piece */
if( tr_bencDictFindList( p, KEY_PROGRESS_CHECKTIME, &m ) )
{
/* This key was added in 2.20.
Load in the timestamp of when we last checked each piece */
for( i=0, n=tor->info.pieceCount; i<n; ++i )
if( tr_bencGetInt( tr_bencListChild( m, i ), &timeChecked ) )
tor->info.pieces[i].timeChecked = (time_t)timeChecked;
}
else if( tr_bencDictFindList( p, KEY_PROGRESS_MTIMES, &m ) )
{
/* This is how it was done pre-2.20... per file. */
for( i=0, n=tr_bencListSize(m); i<n; ++i )
{
/* get the timestamp of file #i */
if( tr_bencGetInt( tr_bencListChild( m, i ), &timeChecked ) )
{
/* walk through all the pieces that are in that file... */
tr_piece_index_t j;
tr_file * file = &tor->info.files[i];
for( j=file->firstPiece; j<=file->lastPiece; ++j )
{
tr_piece * piece = &tor->info.pieces[j];
/* If the piece's timestamp is unset from earlier,
* set it here. */
if( piece->timeChecked == 0 )
piece->timeChecked = timeChecked;
/* If the piece's timestamp is *newer* timeChecked,
* the piece probably spans more than one file.
* To be safe, let's use the older timestamp. */
if( piece->timeChecked > timeChecked )
piece->timeChecked = timeChecked;
}
}
}
}
err = NULL;
if( tr_bencDictFindStr( p, KEY_PROGRESS_HAVE, &str ) )