Ignore:
Timestamp:
May 19, 2010, 7:02:25 PM (12 years ago)
Author:
charles
Message:

(trunk libT) #2929 "persistent tracker error messages in main window" -- experimental fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r10663 r10664  
    348348    va_start( ap, fmt );
    349349    tor->error = TR_STAT_LOCAL_ERROR;
     350    tor->errorTracker[0] = '\0';
    350351    evutil_vsnprintf( tor->errorString, sizeof( tor->errorString ), fmt, ap );
    351352    va_end( ap );
     353}
     354
     355static void
     356tr_torrentClearError( tr_torrent * tor )
     357{
     358    assert( tr_isTorrent( tor ) );
     359
     360    tor->error = TR_STAT_OK;
     361    tor->errorString[0] = '\0';
     362    tor->errorTracker[0] = '\0';
    352363}
    353364
     
    387398            tr_torerr( tor, _( "Tracker warning: \"%s\"" ), event->text );
    388399            tor->error = TR_STAT_TRACKER_WARNING;
     400            tr_strlcpy( tor->errorTracker, event->tracker, sizeof( tor->errorTracker ) );
    389401            tr_strlcpy( tor->errorString, event->text, sizeof( tor->errorString ) );
    390402            break;
     
    393405            tr_torerr( tor, _( "Tracker error: \"%s\"" ), event->text );
    394406            tor->error = TR_STAT_TRACKER_ERROR;
     407            tr_strlcpy( tor->errorTracker, event->tracker, sizeof( tor->errorTracker ) );
    395408            tr_strlcpy( tor->errorString, event->text, sizeof( tor->errorString ) );
    396409            break;
     
    398411        case TR_TRACKER_ERROR_CLEAR:
    399412            if( tor->error != TR_STAT_LOCAL_ERROR )
    400             {
    401                 tor->error = TR_STAT_OK;
    402                 tor->errorString[0] = '\0';
    403             }
     413                tr_torrentClearError( tor );
    404414            break;
    405415    }
     
    13641374        const time_t now = tr_time( );
    13651375        tor->isRunning = TRUE;
    1366         tor->error = TR_STAT_OK;
    1367         tor->errorString[0] = '\0';
    13681376        tor->completeness = tr_cpGetStatus( &tor->completion );
    13691377        tor->startDate = tor->anyDate = now;
     1378        tr_torrentClearError( tor );
    13701379
    13711380        tr_torrentResetTransferStats( tor );
     
    22102219        /* cleanup */
    22112220        tr_bencFree( &metainfo );
     2221
     2222        /* if we had a tracker-related error on this torrent,
     2223         * and that tracker's been removed,
     2224         * then clear the error */
     2225        if(    ( tor->error == TR_STAT_TRACKER_WARNING )
     2226            || ( tor->error == TR_STAT_TRACKER_ERROR ) )
     2227        {
     2228            tr_bool clear = TRUE;
     2229
     2230            for( i=0; clear && i<trackerCount; ++i )
     2231                if( !strcmp( trackers[i].announce, tor->errorTracker ) )
     2232                    clear = FALSE;
     2233
     2234            if( clear )
     2235                tr_torrentClearError( tor );
     2236        }
    22122237
    22132238        /* tell the announcer to reload this torrent's tracker list */
Note: See TracChangeset for help on using the changeset viewer.