Ignore:
Timestamp:
Oct 26, 2007, 3:02:23 AM (15 years ago)
Author:
charles
Message:

Quick & dirty fix to crasher ticket #415.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fastresume.c

    r3568 r3572  
    331331
    332332static int
    333 loadFallbackDestination( tr_torrent * tor, FILE * fp )
     333loadDestination( tr_torrent * tor, FILE * fp, const char * destination, int argIsFallback )
    334334{
    335335    int pathlen = 0;
    336336    char path[MAX_PATH_LENGTH];
    337     const int haveDestination = tor->destination && *tor->destination;
    338337
    339338    for( ;; ) {
     
    348347    path[pathlen] = '\0';
    349348
    350     if( pathlen && !haveDestination ) {
    351         tr_free( tor->destination );
    352         tor->destination = tr_strdup( path );
    353     }
     349    if( argIsFallback )
     350        tor->destination = tr_strdup( pathlen ? path : destination );
     351    else
     352        tor->destination = tr_strdup( destination && *destination ? destination : path );
    354353
    355354    return TR_OK;
     
    526525static uint64_t
    527526fastResumeLoadImpl ( tr_torrent   * tor,
    528                      tr_bitfield  * uncheckedPieces )
     527                     tr_bitfield  * uncheckedPieces,
     528                     const char   * destination,
     529                     int            argIsFallback )
    529530{
    530531    char      path[MAX_PATH_LENGTH];
     
    630631            case FR_ID_DESTINATION:
    631632                {
    632                     const int rret = loadFallbackDestination( tor, file );
     633                    const int rret = loadDestination( tor, file, destination, argIsFallback );
    633634
    634635                    if( rret && ( feof(file) || ferror(file) ) )
     
    773774uint64_t
    774775tr_fastResumeLoad( tr_torrent   * tor,
    775                    tr_bitfield  * uncheckedPieces )
    776 {
    777     const uint64_t ret = fastResumeLoadImpl( tor, uncheckedPieces );
     776                   tr_bitfield  * uncheckedPieces,
     777                   const char   * destination,
     778                   int            argIsFallback )
     779{
     780    const uint64_t ret = fastResumeLoadImpl( tor, uncheckedPieces, destination, argIsFallback );
    778781
    779782    if( ! ( ret & TR_FR_PROGRESS ) )
    780783        tr_bitfieldAddRange( uncheckedPieces, 0, tor->info.pieceCount );
    781784
     785    if( !tor->destination )
     786        tor->destination = tr_strdup( destination );
     787
    782788    return ret;
    783789}
Note: See TracChangeset for help on using the changeset viewer.