From b19c79cff874e9182d0fb45b007ce51cd809611f Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Wed, 21 Oct 2009 23:13:02 +0000 Subject: [PATCH] more efficient time machine location check --- macosx/Torrent.m | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/macosx/Torrent.m b/macosx/Torrent.m index fcb10c8d4..7e66beea4 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -253,7 +253,6 @@ int trashDataFile(const char * filename) [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateQueue" object: self]; //when the data first appears, update time machine exclusion - #warning perhaps always check to get if the file is moved through rpc if (!fTimeMachineExclude) [self updateTimeMachineExclude]; } @@ -480,6 +479,8 @@ int trashDataFile(const char * filename) [alert runModal]; [alert release]; } + + [self updateTimeMachineExclude]; } - (void) copyTorrentFileTo: (NSString *) path @@ -1459,23 +1460,40 @@ int trashDataFile(const char * filename) - (void) updateTimeMachineExclude { - NSString * newLocation = [self dataLocation]; - - if (fTimeMachineExclude && newLocation && [fTimeMachineExclude isEqualToString: newLocation] && ![self allDownloaded]) - return; + NSString * newLocation = nil; + BOOL checkedNewLocation = NO; if (fTimeMachineExclude) { + //long-winded way of saying "return if the locations are the same and not all is downloaded" + if (![self allDownloaded]) + { + newLocation = [self dataLocation]; + checkedNewLocation = YES; + + if ([fTimeMachineExclude isEqualToString: newLocation]) + return; + } + [self setTimeMachineExclude: NO forPath: fTimeMachineExclude]; [fTimeMachineExclude release]; fTimeMachineExclude = nil; } - if (newLocation && ![self allDownloaded]) + if (![self allDownloaded]) { - [self setTimeMachineExclude: YES forPath: newLocation]; - [fTimeMachineExclude release]; - fTimeMachineExclude = [newLocation retain]; + if (!checkedNewLocation) + { + newLocation = [self dataLocation]; + checkedNewLocation = YES; + } + + if (newLocation) + { + [self setTimeMachineExclude: YES forPath: newLocation]; + [fTimeMachineExclude release]; + fTimeMachineExclude = [newLocation retain]; + } } } @@ -1715,7 +1733,6 @@ int trashDataFile(const char * filename) { fStat = tr_torrentStat(fHandle); //don't call update yet to avoid auto-stop - BOOL canMove; switch ([status intValue]) { case TR_SEED: