Ignore:
Timestamp:
May 11, 2007, 6:56:59 PM (15 years ago)
Author:
livings124
Message:

separate code for determining if there is a download with same name and location

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r1829 r1868  
    239239}
    240240
    241 void tr_torrentStart( tr_torrent_t * tor )
    242 {
    243     char name[32];
     241int tr_torrentDuplicateDownload( tr_torrent_t * tor )
     242{
    244243    tr_torrent_t * current, * next;
    245244   
    246     if( tor->status & ( TR_STATUS_STOPPING | TR_STATUS_STOPPED ) )
    247     {
    248         /* Join the thread first */
    249         torrentReallyStop( tor );
    250     }
    251    
    252     /* Don't start if a torrent with the same name and destination is already active */
     245    /* Check if a torrent with the same name and destination is already active */
    253246    for( current = tor->handle->torrentList; current; current = current->next )
    254247    {
     
    257250            && !strcmp( tor->info.name, current->info.name ) )
    258251        {
    259             tor->error = TR_ERROR_IO_DUP_NAME;
    260             snprintf( tor->errorString, sizeof( tor->errorString ),
    261                           "%s", tr_errorString( TR_ERROR_IO_DUP_NAME ) );
    262             return;
    263         }
     252            return 1;
     253        }
     254    }
     255    return 0;
     256}
     257
     258void tr_torrentStart( tr_torrent_t * tor )
     259{
     260    char name[32];
     261   
     262    if( tor->status & ( TR_STATUS_STOPPING | TR_STATUS_STOPPED ) )
     263    {
     264        /* Join the thread first */
     265        torrentReallyStop( tor );
     266    }
     267   
     268    /* Don't start if a torrent with the same name and destination is already active */
     269    if( tr_torrentDuplicateDownload( tor ) )
     270    {
     271        tor->error = TR_ERROR_IO_DUP_DOWNLOAD;
     272        snprintf( tor->errorString, sizeof( tor->errorString ),
     273                    "%s", tr_errorString( TR_ERROR_IO_DUP_DOWNLOAD ) );
     274        return;
    264275    }
    265276
Note: See TracChangeset for help on using the changeset viewer.