Ignore:
Timestamp:
Dec 9, 2009, 3:00:20 AM (12 years ago)
Author:
charles
Message:

(trunk libT) the deleteFunc passed in as the second argument to tr_torrentDeleteLocalData() should /not/ be called unless the file being passed to it actually exists. Reported by livings124

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r9681 r9689  
    23172317
    23182318static void
     2319deleteLocalFile( const char * filename, tr_fileFunc fileFunc )
     2320{
     2321    struct stat sb;
     2322    if( !stat( filename, &sb ) ) /* if file exists... */
     2323        fileFunc( filename );
     2324}
     2325
     2326static void
    23192327deleteLocalData( tr_torrent * tor, tr_fileFunc fileFunc )
    23202328{
     
    23452353    for( i=0; i<n; ++i )
    23462354        if( tr_ptrArrayFindSorted( &dirtyFolders, s[i], vstrcmp ) == NULL )
    2347             fileFunc( s[i] );
     2355            deleteLocalFile( s[i], fileFunc );
    23482356
    23492357    /* now blow away any remaining torrent files, such as torrent files in dirty folders */
    23502358    for( f=0; f<tor->info.fileCount; ++f ) {
    23512359        char * path = tr_buildPath( tor->currentDir, tor->info.files[f].name, NULL );
    2352         fileFunc( path );
     2360        deleteLocalFile( path, fileFunc );
    23532361        tr_free( path );
    23542362    }
     
    23672375#ifdef SYS_DARWIN
    23682376            char * dsStore = tr_buildPath( s[i], ".DS_Store", NULL );
    2369             fileFunc( dsStore );
     2377            deleteLocalFile( dsStore, fileFunc );
    23702378            tr_free( dsStore );
    23712379#endif
    2372             fileFunc( s[i] );
     2380            deleteLocalFile( s[i], fileFunc );
    23732381        }
    23742382        tr_ptrArrayDestruct( &cleanFolders, NULL );
     
    24042412        /* torrent only has one file */
    24052413        char * path = tr_buildPath( tor->currentDir, tor->info.files[0].name, NULL );
    2406         fileFunc( path );
     2414        deleteLocalFile( path, fileFunc );
    24072415        tr_free( path );
    24082416
    24092417        tmp = tr_torrentBuildPartial( tor, 0 );
    24102418        path = tr_buildPath( tor->currentDir, tmp, NULL );
    2411         fileFunc( path );
     2419        deleteLocalFile( path, fileFunc );
    24122420        tr_free( path );
    24132421        tr_free( tmp );
Note: See TracChangeset for help on using the changeset viewer.