From 0f75cc77991b173d64f7590bee0a4defa7669275 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Tue, 31 Oct 2006 20:53:10 +0000 Subject: [PATCH] autoimport can now tell if not opening was a result of the torrent already existing or not being supported --- macosx/Controller.m | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/macosx/Controller.m b/macosx/Controller.m index b339660fd..8fb6e02cb 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1569,18 +1569,27 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy { if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame) { - oldCount = [fTorrents count]; - [self openFiles: [NSArray arrayWithObject: [path stringByAppendingPathComponent: file]]]; + int error; + tr_torrent_t * tempTor = tr_torrentInit(fLib, [path UTF8String], 0, & error); - //import only actually happened if the torrent array is larger - if (oldCount < [fTorrents count]) + if (tempTor) { - [GrowlApplicationBridge notifyWithTitle: NSLocalizedString(@"Torrent File Auto Added", - "Growl notification title") description: file - notificationName: GROWL_AUTO_ADD iconData: nil priority: 0 isSticky: NO clickContext: nil]; + tr_torrentClose(fLib, tempTor); + + int count = [fTorrents count]; + [self openFiles: [NSArray arrayWithObject: [path stringByAppendingPathComponent: file]]]; + + //check if torrent was opened + if ([fTorrents count] > count) + { + [GrowlApplicationBridge notifyWithTitle: NSLocalizedString(@"Torrent File Auto Added", + "Growl notification title") description: file + notificationName: GROWL_AUTO_ADD iconData: nil priority: 0 isSticky: NO clickContext: nil]; + } } - else - [fAutoImportedNames removeObjectIdenticalTo: file]; //failed to import, possibly because not fully downloaded + else if (error != TR_EUNSUPPORTED || error != TR_EDUPLICATE) + [fAutoImportedNames removeObjectIdenticalTo: file]; //failed to import for unknown reason, so try again later + else; } }