Changeset 1061 for trunk


Ignore:
Timestamp:
Nov 9, 2006, 5:54:12 AM (15 years ago)
Author:
livings124
Message:

auto-import should work better with multiple torrents and always ask enabled

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r1058 r1061  
    15691569    [fAutoImportedNames setArray: importedNames];
    15701570   
    1571     NSEnumerator * enumerator = [newNames objectEnumerator];
    15721571    NSString * file;
    1573     unsigned oldCount;
    1574     while ((file = [enumerator nextObject]))
    1575     {
    1576         if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame)
     1572    int i;
     1573    for (i = [newNames count] - 1; i >= 0; i--)
     1574    {
     1575        if ([[[newNames objectAtIndex: i] pathExtension] caseInsensitiveCompare: @"torrent"] != NSOrderedSame)
     1576            [newNames removeObjectAtIndex: i];
     1577        else
     1578            [newNames replaceObjectAtIndex: i withObject: [path stringByAppendingPathComponent: [newNames objectAtIndex: i]]];
     1579    }
     1580   
     1581    NSEnumerator * enumerator;
     1582    if (![[fDefaults stringForKey: @"DownloadChoice"] isEqualToString: @"Ask"])
     1583    {
     1584        enumerator = [newNames objectEnumerator];
     1585        unsigned oldCount;
     1586        while ((file = [enumerator nextObject]))
    15771587        {
    15781588            int count = [fTorrents count];
    1579             [self openFiles: [NSArray arrayWithObject: [path stringByAppendingPathComponent: file]]];
     1589            [self openFiles: [NSArray arrayWithObject: file]];
    15801590           
    15811591            //check if torrent was opened
     
    15831593            {
    15841594                [GrowlApplicationBridge notifyWithTitle: NSLocalizedString(@"Torrent File Auto Added",
    1585                     "Growl notification title") description: file
     1595                    "Growl notification title") description: [file lastPathComponent]
    15861596                    notificationName: GROWL_AUTO_ADD iconData: nil priority: 0 isSticky: NO clickContext: nil];
    15871597            }
    1588             else
    1589             {
    1590                 //create a temporary torrent to check if it didn't import because of error
    1591                 int error;
    1592                 tr_torrent_t * tempTor = tr_torrentInit(fLib, [[path stringByAppendingPathComponent: file] UTF8String],
    1593                                                     0, & error);
    1594                
    1595                 if (tempTor)
    1596                     tr_torrentClose(fLib, tempTor);
    1597                 else if (error != TR_EUNSUPPORTED && error != TR_EDUPLICATE)
    1598                     [fAutoImportedNames removeObjectIdenticalTo: file]; //can try to import later
    1599                 else;
    1600             }
    1601         }
     1598        }
     1599    }
     1600    else
     1601    {
     1602        [self openFiles: newNames];
     1603    }
     1604   
     1605    //create temporary torrents to check if an import fails because of an error
     1606    enumerator = [newNames objectEnumerator];
     1607    while ((file = [enumerator nextObject]))
     1608    {
     1609        int error;
     1610        tr_torrent_t * tempTor = tr_torrentInit(fLib, [file UTF8String], 0, & error);
     1611       
     1612        if (tempTor)
     1613            tr_torrentClose(fLib, tempTor);
     1614        else if (error != TR_EUNSUPPORTED && error != TR_EDUPLICATE)
     1615            [fAutoImportedNames removeObjectIdenticalTo: [file lastPathComponent]]; //can try to import later
     1616        else;
    16021617    }
    16031618   
Note: See TracChangeset for help on using the changeset viewer.