1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-04 21:43:03 +00:00

only create temporary torrent if import failed

This commit is contained in:
Mitchell Livingston 2006-10-31 21:21:47 +00:00
parent cd0b6875da
commit d5ca0624a4

View file

@ -509,6 +509,8 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
{ {
NSString * torrentPath; NSString * torrentPath;
Torrent * torrent; Torrent * torrent;
//determine next file that can be opened
do do
{ {
if ([files count] == 0) //recursive base case if ([files count] == 0) //recursive base case
@ -1569,28 +1571,29 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
{ {
if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame) if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame)
{ {
int error; int count = [fTorrents count];
tr_torrent_t * tempTor = tr_torrentInit(fLib, [[path stringByAppendingPathComponent: file] UTF8String], [self openFiles: [NSArray arrayWithObject: [path stringByAppendingPathComponent: file]]];
0, & error);
if (tempTor) //check if torrent was opened
if ([fTorrents count] > count)
{ {
tr_torrentClose(fLib, tempTor); [GrowlApplicationBridge notifyWithTitle: NSLocalizedString(@"Torrent File Auto Added",
"Growl notification title") description: file
int count = [fTorrents count]; notificationName: GROWL_AUTO_ADD iconData: nil priority: 0 isSticky: NO clickContext: nil];
[self openFiles: [NSArray arrayWithObject: [path stringByAppendingPathComponent: file]]]; }
else
//check if torrent was opened {
if ([fTorrents count] > count) //create a temporary torrent to check if it didn't import because of error
{ int error;
[GrowlApplicationBridge notifyWithTitle: NSLocalizedString(@"Torrent File Auto Added", tr_torrent_t * tempTor = tr_torrentInit(fLib, [[path stringByAppendingPathComponent: file] UTF8String],
"Growl notification title") description: file 0, & error);
notificationName: GROWL_AUTO_ADD iconData: nil priority: 0 isSticky: NO clickContext: nil];
} if (tempTor)
tr_torrentClose(fLib, tempTor);
else if (error != TR_EUNSUPPORTED && error != TR_EDUPLICATE)
[fAutoImportedNames removeObjectIdenticalTo: file]; //can try to import later
else;
} }
else if (error != TR_EUNSUPPORTED && error != TR_EDUPLICATE)
[fAutoImportedNames removeObjectIdenticalTo: file]; //failed to import for unknown reason, so try again later
else;
} }
} }