auto-import should work better with multiple torrents and always ask enabled
This commit is contained in:
parent
9b3802f23a
commit
ca5e8c26bc
|
@ -1568,38 +1568,53 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
[newNames removeObjectsInArray: fAutoImportedNames];
|
[newNames removeObjectsInArray: fAutoImportedNames];
|
||||||
[fAutoImportedNames setArray: importedNames];
|
[fAutoImportedNames setArray: importedNames];
|
||||||
|
|
||||||
NSEnumerator * enumerator = [newNames objectEnumerator];
|
|
||||||
NSString * file;
|
NSString * file;
|
||||||
unsigned oldCount;
|
int i;
|
||||||
while ((file = [enumerator nextObject]))
|
for (i = [newNames count] - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame)
|
if ([[[newNames objectAtIndex: i] pathExtension] caseInsensitiveCompare: @"torrent"] != NSOrderedSame)
|
||||||
|
[newNames removeObjectAtIndex: i];
|
||||||
|
else
|
||||||
|
[newNames replaceObjectAtIndex: i withObject: [path stringByAppendingPathComponent: [newNames objectAtIndex: i]]];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSEnumerator * enumerator;
|
||||||
|
if (![[fDefaults stringForKey: @"DownloadChoice"] isEqualToString: @"Ask"])
|
||||||
|
{
|
||||||
|
enumerator = [newNames objectEnumerator];
|
||||||
|
unsigned oldCount;
|
||||||
|
while ((file = [enumerator nextObject]))
|
||||||
{
|
{
|
||||||
int count = [fTorrents count];
|
int count = [fTorrents count];
|
||||||
[self openFiles: [NSArray arrayWithObject: [path stringByAppendingPathComponent: file]]];
|
[self openFiles: [NSArray arrayWithObject: file]];
|
||||||
|
|
||||||
//check if torrent was opened
|
//check if torrent was opened
|
||||||
if ([fTorrents count] > count)
|
if ([fTorrents count] > count)
|
||||||
{
|
{
|
||||||
[GrowlApplicationBridge notifyWithTitle: NSLocalizedString(@"Torrent File Auto Added",
|
[GrowlApplicationBridge notifyWithTitle: NSLocalizedString(@"Torrent File Auto Added",
|
||||||
"Growl notification title") description: file
|
"Growl notification title") description: [file lastPathComponent]
|
||||||
notificationName: GROWL_AUTO_ADD iconData: nil priority: 0 isSticky: NO clickContext: nil];
|
notificationName: GROWL_AUTO_ADD iconData: nil priority: 0 isSticky: NO clickContext: nil];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
//create a temporary torrent to check if it didn't import because of error
|
|
||||||
int error;
|
|
||||||
tr_torrent_t * tempTor = tr_torrentInit(fLib, [[path stringByAppendingPathComponent: file] UTF8String],
|
|
||||||
0, & error);
|
|
||||||
|
|
||||||
if (tempTor)
|
|
||||||
tr_torrentClose(fLib, tempTor);
|
|
||||||
else if (error != TR_EUNSUPPORTED && error != TR_EDUPLICATE)
|
|
||||||
[fAutoImportedNames removeObjectIdenticalTo: file]; //can try to import later
|
|
||||||
else;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[self openFiles: newNames];
|
||||||
|
}
|
||||||
|
|
||||||
|
//create temporary torrents to check if an import fails because of an error
|
||||||
|
enumerator = [newNames objectEnumerator];
|
||||||
|
while ((file = [enumerator nextObject]))
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
tr_torrent_t * tempTor = tr_torrentInit(fLib, [file UTF8String], 0, & error);
|
||||||
|
|
||||||
|
if (tempTor)
|
||||||
|
tr_torrentClose(fLib, tempTor);
|
||||||
|
else if (error != TR_EUNSUPPORTED && error != TR_EDUPLICATE)
|
||||||
|
[fAutoImportedNames removeObjectIdenticalTo: [file lastPathComponent]]; //can try to import later
|
||||||
|
else;
|
||||||
|
}
|
||||||
|
|
||||||
[newNames release];
|
[newNames release];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue