Changeset 11763


Ignore:
Timestamp:
Jan 24, 2011, 5:11:16 AM (11 years ago)
Author:
jordan
Message:

(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... :(

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/resume.c

    r11709 r11763  
    6464
    6565#define KEY_PROGRESS_CHECKTIME "time-checked"
     66#define KEY_PROGRESS_MTIMES    "mtimes"
    6667#define KEY_PROGRESS_BITFIELD  "bitfield"
    6768#define KEY_PROGRESS_HAVE      "have"
     
    452453        int64_t  timeChecked;
    453454
    454         /* load in the timestamp of when we last checked each piece */
    455455        if( tr_bencDictFindList( p, KEY_PROGRESS_CHECKTIME, &m ) )
     456        {
     457            /* This key was added in 2.20.
     458               Load in the timestamp of when we last checked each piece */
    456459            for( i=0, n=tor->info.pieceCount; i<n; ++i )
    457460                if( tr_bencGetInt( tr_bencListChild( m, i ), &timeChecked ) )
    458461                    tor->info.pieces[i].timeChecked = (time_t)timeChecked;
     462        }
     463        else if( tr_bencDictFindList( p, KEY_PROGRESS_MTIMES, &m ) )
     464        {
     465            /* This is how it was done pre-2.20... per file. */
     466            for( i=0, n=tr_bencListSize(m); i<n; ++i )
     467            {
     468                /* get the timestamp of file #i */
     469                if( tr_bencGetInt( tr_bencListChild( m, i ), &timeChecked ) )
     470                {
     471                    /* walk through all the pieces that are in that file... */
     472                    tr_piece_index_t j;
     473                    tr_file * file = &tor->info.files[i];
     474                    for( j=file->firstPiece; j<=file->lastPiece; ++j )
     475                    {
     476                        tr_piece * piece = &tor->info.pieces[j];
     477
     478                        /* If the piece's timestamp is unset from earlier,
     479                         * set it here. */
     480                        if( piece->timeChecked == 0 )
     481                            piece->timeChecked = timeChecked;
     482
     483                        /* If the piece's timestamp is *newer* timeChecked,
     484                         * the piece probably spans more than one file.
     485                         * To be safe, let's use the older timestamp. */
     486                        if( piece->timeChecked > timeChecked )
     487                            piece->timeChecked = timeChecked;
     488                    }
     489                }
     490            }
     491        }
    459492
    460493        err = NULL;
Note: See TracChangeset for help on using the changeset viewer.