Changeset 1868


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

Location:
trunk
Files:
5 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
  • trunk/libtransmission/transmission.h

    r1861 r1868  
    6565 **********************************************************************/
    6666/* General errors */
    67 #define TR_OK                   0x00000000
    68 #define TR_ERROR                0x81000000
    69 #define TR_ERROR_ASSERT         0x82000000
     67#define TR_OK                       0x00000000
     68#define TR_ERROR                    0x81000000
     69#define TR_ERROR_ASSERT             0x82000000
    7070/* I/O errors */
    71 #define TR_ERROR_IO_MASK        0x000000FF
    72 #define TR_ERROR_IO_PARENT      0x80000001
    73 #define TR_ERROR_IO_PERMISSIONS 0x80000002
    74 #define TR_ERROR_IO_SPACE       0x80000004
    75 #define TR_ERROR_IO_RESOURCES   0x80000008
    76 #define TR_ERROR_IO_DUP_NAME    0x8000000A
    77 #define TR_ERROR_IO_OTHER       0x80000010
     71#define TR_ERROR_IO_MASK            0x000000FF
     72#define TR_ERROR_IO_PARENT          0x80000001
     73#define TR_ERROR_IO_PERMISSIONS     0x80000002
     74#define TR_ERROR_IO_SPACE           0x80000004
     75#define TR_ERROR_IO_RESOURCES       0x80000008
     76#define TR_ERROR_IO_DUP_DOWNLOAD    0x8000000A
     77#define TR_ERROR_IO_OTHER           0x80000010
    7878/* Misc */
    79 #define TR_ERROR_TC_MASK        0x00000F00
    80 #define TR_ERROR_TC_ERROR       0x80000100
    81 #define TR_ERROR_TC_WARNING     0x80000200
     79#define TR_ERROR_TC_MASK            0x00000F00
     80#define TR_ERROR_TC_ERROR           0x80000100
     81#define TR_ERROR_TC_WARNING         0x80000200
    8282
    8383#define TR_ERROR_ISSET( num, code ) ( (code) == ( (code) & (num) ) )
     
    270270int tr_torrentScrape( tr_torrent_t *, int * s, int * l, int * d );
    271271
     272void   tr_torrentSetFolder( tr_torrent_t *, const char * );
     273char * tr_torrentGetFolder( tr_torrent_t * );
     274
     275int tr_torrentDuplicateDownload( tr_torrent_t * tor );
     276
    272277/***********************************************************************
    273278 * tr_torrentStart
     
    276281 * therefore tr_torrentStart returns immediately.
    277282 **********************************************************************/
    278 void   tr_torrentSetFolder( tr_torrent_t *, const char * );
    279 char * tr_torrentGetFolder( tr_torrent_t * );
    280283void   tr_torrentStart( tr_torrent_t * );
    281284
  • trunk/libtransmission/utils.c

    r1829 r1868  
    396396        case TR_ERROR_IO_SPACE:
    397397            return "Insufficient free space";
    398         case TR_ERROR_IO_DUP_NAME:
     398        case TR_ERROR_IO_DUP_DOWNLOAD:
    399399            return "Already active transfer with same name and download folder";
    400400        case TR_ERROR_IO_RESOURCES:
  • trunk/macosx/InfoWindowController.m

    r1867 r1868  
    876876        [descriptors addObject: descriptor];
    877877       
    878         useSecond = ![[descriptor key] isEqualToString: @"IP"];
    879         asc = [descriptor ascending];
     878        if ((useSecond = ![[descriptor key] isEqualToString: @"IP"]))
     879        {
     880            #warning different for different sorts
     881            NSLog(@"%@", [[fPeerTable highlightedTableColumn] identifier]);
     882           
     883            asc = [descriptor ascending];
     884        }
    880885    }
    881886   
     
    883888    if (useSecond)
    884889    {
    885         #warning different for different sorts
    886890        NSSortDescriptor * secondDescriptor = [[NSSortDescriptor alloc] initWithKey: @"IP" ascending: asc
    887891                                                                        selector: @selector(compareIP:)];
  • trunk/macosx/Torrent.m

    r1866 r1868  
    765765            [alert setInformativeText: [NSString stringWithFormat:
    766766                            NSLocalizedString(@"The move operation of \"%@\" cannot be done.",
    767                                                 "   Move error alert -> message"), [self name]]];
     767                                                "Move error alert -> message"), [self name]]];
    768768            [alert addButtonWithTitle: NSLocalizedString(@"OK", "Move error alert -> button")];
    769769           
Note: See TracChangeset for help on using the changeset viewer.