Changeset 3387


Ignore:
Timestamp:
Oct 13, 2007, 3:58:54 AM (15 years ago)
Author:
charles
Message:

fix r3379 bug that forced us to recheck the torrents every startup

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fastresume.c

    r3379 r3387  
    195195    fwrite( &version, 4, 1, file );
    196196
     197    if( TRUE ) /* FR_ID_DESTINATION */
     198    {
     199        const char * d = tor->destination ? tor->destination : "";
     200        const int byteCount = strlen( d ) + 1;
     201        fastResumeWriteData( FR_ID_DESTINATION, d, 1, byteCount, file );
     202    }
     203
    197204    /* Write progress data */
    198205    if (1) {
     
    284291        const char is_running = tor->isRunning ? 't' : 'f';
    285292        fastResumeWriteData( FR_ID_RUN, &is_running, 1, 1, file );
    286     }
    287 
    288     if( TRUE ) /* FR_ID_DESTINATION */
    289     {
    290         const char * d = tor->destination ? tor->destination : "";
    291         const int byteCount = strlen( d ) + 1;
    292         fastResumeWriteData( FR_ID_DESTINATION, d, 1, byteCount, file );
    293293    }
    294294
     
    514514static uint64_t
    515515fastResumeLoadImpl ( tr_torrent   * tor,
     516                     const char   * fallbackDestination,
    516517                     tr_bitfield  * uncheckedPieces )
    517518{
     
    562563    while( 1 == fread( &id, 1, 1, file ) && 1 == fread( &len, 4, 1, file ) )
    563564    {
     565fprintf( stderr, "reading id %d\n", (int)id );
    564566        switch( id )
    565567        {
     
    626628                    }
    627629
    628                     ret |= TR_FR_DESTINATION;;
     630                    if( tor->destination == NULL )
     631                        tor->destination = tr_strdup( fallbackDestination );
     632
     633                    ret |= TR_FR_DESTINATION;
    629634                    continue;
    630635                }
     
    741746        fseek( file, len, SEEK_CUR );
    742747    }
     748fprintf( stderr, "\n\n" );
    743749
    744750    fclose( file );
     
    748754uint64_t
    749755tr_fastResumeLoad( tr_torrent   * tor,
     756                   const char   * fallbackDestination,
    750757                   tr_bitfield  * uncheckedPieces )
    751758{
    752     const uint64_t ret = fastResumeLoadImpl( tor, uncheckedPieces );
     759    const uint64_t ret = fastResumeLoadImpl( tor, fallbackDestination, uncheckedPieces );
    753760
    754761    if( ! ( ret & TR_FR_PROGRESS ) )
  • trunk/libtransmission/fastresume.h

    r3379 r3387  
    4444 * Returns a bitwise-or'ed set of the data loaded from fastresume
    4545 */
    46 uint64_t tr_fastResumeLoad( tr_torrent         * tor,
    47                             struct tr_bitfield * uncheckedPieces );
     46uint64_t tr_fastResumeLoad( tr_torrent          * tor,
     47                            const char          * fallbackDestination,
     48                            struct tr_bitfield  * uncheckedPieces );
    4849
    4950#endif
  • trunk/libtransmission/torrent.c

    r3379 r3387  
    339339
    340340    uncheckedPieces = tr_bitfieldNew( tor->info.pieceCount );
    341     loaded = tr_fastResumeLoad( tor, uncheckedPieces );
    342 
    343     /* a path passed in by the user overrides
    344        the one loaded by fastresume... */
    345     if( destination && *destination ) {
    346         tr_free( tor->destination );
    347         tor->destination = tr_strdup( destination );
    348     }
     341
     342    loaded = tr_fastResumeLoad( tor, destination, uncheckedPieces );
    349343
    350344    /* the `paused' flag has highest precedence...
Note: See TracChangeset for help on using the changeset viewer.