Changeset 13418


Ignore:
Timestamp:
Aug 6, 2012, 3:49:59 AM (9 years ago)
Author:
livings124
Message:

Tweak how we first load in the torrent file list. This time submit the right file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Torrent.m

    r13379 r13418  
    4545
    4646- (void) createFileList;
    47 - (void) insertPath: (NSMutableArray *) components forParent: (FileListNode *) parent fileSize: (uint64_t) size
     47- (void) insertPathForComponents: (NSArray *) components withComponentIndex: (NSUInteger) componentIndex forParent: (FileListNode *) parent fileSize: (uint64_t) size
    4848    index: (NSInteger) index flatList: (NSMutableArray *) flatFileList;
    4949- (void) sortFileList: (NSMutableArray *) fileNodes;
     
    17141714            NSAssert1([pathComponents count] >= 2, @"Not enough components in path %@", fullPath);
    17151715           
    1716             NSString * path = [pathComponents objectAtIndex: 0];
    1717             NSString * name = [pathComponents objectAtIndex: 1];
     1716            NSString * path = pathComponents[0];
     1717            NSString * name = pathComponents[1];
    17181718           
    17191719            if ([pathComponents count] > 2)
     
    17361736                }
    17371737               
    1738                 NSMutableArray * trimmedComponents = [NSMutableArray arrayWithArray: [pathComponents subarrayWithRange: NSMakeRange(2, [pathComponents count]-2)]];
    1739                
    17401738                [node insertIndex: i withSize: file->length];
    1741                 [self insertPath: trimmedComponents forParent: node fileSize: file->length index: i flatList: flatFileList];
     1739                [self insertPathForComponents: pathComponents withComponentIndex: 2 forParent: node fileSize: file->length index: i flatList: flatFileList];
    17421740            }
    17431741            else
     
    17651763}
    17661764
    1767 - (void) insertPath: (NSMutableArray *) components forParent: (FileListNode *) parent fileSize: (uint64_t) size
     1765- (void) insertPathForComponents: (NSArray *) components withComponentIndex: (NSUInteger) componentIndex forParent: (FileListNode *) parent fileSize: (uint64_t) size
    17681766    index: (NSInteger) index flatList: (NSMutableArray *) flatFileList
    17691767{
    1770     NSString * name = [components objectAtIndex: 0];
    1771     const BOOL isFolder = [components count] > 1;
     1768    NSParameterAssert([components count] > 0);
     1769    NSParameterAssert(componentIndex < [components count]);
     1770   
     1771    NSString * name = components[componentIndex];
     1772    const BOOL isFolder = componentIndex < ([components count]-1);
    17721773   
    17731774    //determine if folder node already exists
     
    17891790        NSString * path = [[parent path] stringByAppendingPathComponent: [parent name]];
    17901791        if (isFolder)
    1791             node = [[FileListNode alloc] initWithFolderName: name path: path torrent: self];
     1792            node = [[[FileListNode alloc] initWithFolderName: name path: path torrent: self] autorelease];
    17921793        else
    17931794        {
    1794             node = [[FileListNode alloc] initWithFileName: name path: path size: size index: index torrent: self];
     1795            node = [[[FileListNode alloc] initWithFileName: name path: path size: size index: index torrent: self] autorelease];
    17951796            [flatFileList addObject: node];
    17961797        }
    17971798       
    17981799        [parent insertChild: node];
    1799         [node release];
    18001800    }
    18011801   
     
    18041804        [node insertIndex: index withSize: size];
    18051805       
    1806         [components removeObjectAtIndex: 0];
    1807         [self insertPath: components forParent: node fileSize: size index: index flatList: flatFileList];
     1806        [self insertPathForComponents: components withComponentIndex: (componentIndex+1) forParent: node fileSize: size index: index flatList: flatFileList];
    18081807    }
    18091808}
Note: See TracChangeset for help on using the changeset viewer.