Ignore:
Timestamp:
Dec 17, 2010, 2:57:19 PM (11 years ago)
Author:
charles
Message:

(trunk libT) #2955 "lazy torrent verification" -- speed up setLocalErrorIfFilesDisappeared(). this makes a big difference when loading a lot of torrents on startup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r11540 r11543  
    739739
    740740static tr_bool
     741hasAnyLocalData( const tr_torrent * tor )
     742{
     743    tr_file_index_t i;
     744    tr_bool has_local_data = FALSE;
     745    const tr_file_index_t n = tor->info.fileCount;
     746
     747    for( i=0; i<n && !has_local_data; ++i )
     748    {
     749        struct stat sb;
     750        char * filename = tr_torrentFindFile( tor, i );
     751
     752        if( filename && !stat( filename, &sb ) )
     753            has_local_data = TRUE;
     754
     755        tr_free( filename );
     756    }
     757
     758    return has_local_data;
     759}
     760
     761static tr_bool
    741762setLocalErrorIfFilesDisappeared( tr_torrent * tor )
    742763{
    743     const tr_bool disappeared = ( tr_cpHaveTotal( &tor->completion ) > 0 ) && ( tr_torrentGetCurrentSizeOnDisk( tor ) == 0 );
     764    const tr_bool disappeared = ( tr_cpHaveTotal( &tor->completion ) > 0 ) && !hasAnyLocalData( tor );
    744765
    745766    if( disappeared )
Note: See TracChangeset for help on using the changeset viewer.