mirror of
https://github.com/transmission/transmission
synced 2025-02-22 14:10:34 +00:00
search for folder nodes concurrently when generating a torrent's file list
This commit is contained in:
parent
bfc288a309
commit
1b4ec4dc4d
1 changed files with 10 additions and 6 deletions
|
@ -1710,10 +1710,14 @@ int trashDataFile(const char * filename)
|
||||||
if ([pathComponents count] > 2)
|
if ([pathComponents count] > 2)
|
||||||
{
|
{
|
||||||
//determine if folder node already exists
|
//determine if folder node already exists
|
||||||
FileListNode * node;
|
__block FileListNode * node = nil;
|
||||||
for (node in fileList)
|
[fileList enumerateObjectsWithOptions: NSEnumerationConcurrent usingBlock: ^(FileListNode * searchNode, NSUInteger idx, BOOL * stop) {
|
||||||
if ([[node name] isEqualToString: name] && [node isFolder])
|
if ([[searchNode name] isEqualToString: name] && [searchNode isFolder])
|
||||||
break;
|
{
|
||||||
|
node = searchNode;
|
||||||
|
*stop = YES;
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
if (!node)
|
if (!node)
|
||||||
{
|
{
|
||||||
|
@ -1722,8 +1726,7 @@ int trashDataFile(const char * filename)
|
||||||
[node release];
|
[node release];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSMutableArray * trimmedComponents = [NSMutableArray arrayWithArray: [pathComponents subarrayWithRange:
|
NSMutableArray * trimmedComponents = [NSMutableArray arrayWithArray: [pathComponents subarrayWithRange: NSMakeRange(2, [pathComponents count]-2)]];
|
||||||
NSMakeRange(2, [pathComponents count]-2)]];
|
|
||||||
|
|
||||||
[node insertIndex: i withSize: file->length];
|
[node insertIndex: i withSize: file->length];
|
||||||
[self insertPath: trimmedComponents forParent: node fileSize: file->length index: i flatList: flatFileList];
|
[self insertPath: trimmedComponents forParent: node fileSize: file->length index: i flatList: flatFileList];
|
||||||
|
@ -1758,6 +1761,7 @@ int trashDataFile(const char * filename)
|
||||||
NSString * name = [components objectAtIndex: 0];
|
NSString * name = [components objectAtIndex: 0];
|
||||||
const BOOL isFolder = [components count] > 1;
|
const BOOL isFolder = [components count] > 1;
|
||||||
|
|
||||||
|
//determine if folder node already exists
|
||||||
__block FileListNode * node = nil;
|
__block FileListNode * node = nil;
|
||||||
if (isFolder)
|
if (isFolder)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue