Changeset 9277


Ignore:
Timestamp:
Oct 10, 2009, 7:55:47 PM (13 years ago)
Author:
livings124
Message:

update for the new tracker verification changes, and use a set instead of an array for removing trackers

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.m

    r9267 r9277  
    14401440    Torrent * torrent = [fTorrents objectAtIndex: 0];
    14411441   
    1442     #warning still update unselected rows
    14431442    //get update tracker stats
    14441443    if ([fTrackerTable editedRow] == -1)
     
    17051704{
    17061705    const NSInteger oldCount = [fTrackers count] - [(TrackerNode *)[fTrackers lastObject] tier];
    1707     NSMutableArray * addresses = [NSMutableArray arrayWithCapacity: oldCount];
     1706    NSMutableSet * addresses = [NSMutableSet setWithCapacity: oldCount];
    17081707   
    17091708    NSIndexSet * indexes = [fTrackerTable selectedRowIndexes];
  • trunk/macosx/Torrent.h

    r9269 r9277  
    133133- (NSMutableArray *) allTrackersFlat; //used by GroupRules
    134134- (BOOL) addTrackerToNewTier: (NSString *) tracker;
    135 - (void) removeTrackersWithAnnounceAddresses: (NSArray *) trackers;
     135- (void) removeTrackersWithAnnounceAddresses: (NSSet *) trackers;
    136136
    137137- (NSString *) comment;
  • trunk/macosx/Torrent.m

    r9227 r9277  
    706706}
    707707
    708 #warning check for duplicates?
    709708- (BOOL) addTrackerToNewTier: (NSString *) tracker
    710709{
     
    713712    if ([tracker rangeOfString: @"://"].location == NSNotFound)
    714713        tracker = [@"http://" stringByAppendingString: tracker];
    715    
    716     if (!tr_httpIsValidURL([tracker UTF8String]))
    717         return NO;
    718714   
    719715    //recreate the tracker structure
     
    726722    trackerStructs[oldTrackerCount].tier = trackerStructs[oldTrackerCount-1].tier + 1;
    727723   
    728     tr_torrentSetAnnounceList(fHandle, trackerStructs, oldTrackerCount+1);
     724    const tr_announce_list_err result = tr_torrentSetAnnounceList(fHandle, trackerStructs, oldTrackerCount+1);
    729725    tr_free(trackerStructs);
    730726   
    731     return YES;
    732 }
    733 
    734 - (void) removeTrackersWithAnnounceAddresses: (NSArray *) trackers
     727    return result == TR_ANNOUNCE_LIST_OK;
     728}
     729
     730- (void) removeTrackersWithAnnounceAddresses: (NSSet *) trackers
    735731{
    736732    //recreate the tracker structure
     
    741737    for (NSInteger oldIndex = 0; oldIndex < oldTrackerCount; ++newCount, ++oldIndex)
    742738    {
    743         if (![trackers containsObject: [NSString stringWithUTF8String: fInfo->trackers[oldIndex].announce]])
     739        if (![trackers member: [NSString stringWithUTF8String: fInfo->trackers[oldIndex].announce]])
    744740            trackerStructs[newCount] = fInfo->trackers[oldIndex];
    745741        else
     
    747743    }
    748744   
    749     tr_torrentSetAnnounceList(fHandle, trackerStructs, newCount);
     745    const tr_announce_list_err result = tr_torrentSetAnnounceList(fHandle, trackerStructs, newCount);
     746    NSAssert1(result == TR_ANNOUNCE_LIST_OK, @"Removing tracker addresses resulted in error: %d", result);
     747   
    750748    tr_free(trackerStructs);
    751749}
Note: See TracChangeset for help on using the changeset viewer.