From cf4566eccbc464e5d36e43a3e36448ac2592ef30 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sat, 5 Jan 2008 04:46:18 +0000 Subject: [PATCH] (hopefully) improve and streamline time machine code --- macosx/Torrent.h | 2 -- macosx/Torrent.m | 19 +++++-------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/macosx/Torrent.h b/macosx/Torrent.h index 0750e28ed..23c347913 100644 --- a/macosx/Torrent.h +++ b/macosx/Torrent.h @@ -71,8 +71,6 @@ typedef enum int fOrderValue, fGroupValue; NSDictionary * fQuickPauseDict; - - BOOL fNeedSetTimeMachine; } - (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (torrentFileState) torrentDelete diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 66d6bb485..a7f01150b 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -239,13 +239,6 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * { fStat = tr_torrentStat(fHandle); - //check if the file is created for Time Machine - if (fNeedSetTimeMachine && [self isActive]) - { - NSURL *url = [NSURL fileURLWithPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]]; - fNeedSetTimeMachine = CSBackupSetItemExcluded((CFURLRef)url, ![self allDownloaded], false) != noErr; - } - //check to stop for ratio float stopRatio; if ([self isSeeding] && (stopRatio = [self actualStopRatio]) != INVALID && [self ratio] >= stopRatio) @@ -1570,10 +1563,8 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * if ([NSApp isOnLeopardOrBetter]) { NSURL *url = [NSURL fileURLWithPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]]; - fNeedSetTimeMachine = CSBackupSetItemExcluded((CFURLRef)url, ![self allDownloaded], false) != noErr; + CSBackupSetItemExcluded((CFURLRef)url, ![self allDownloaded], true); } - else - fNeedSetTimeMachine = NO; return self; } @@ -1670,7 +1661,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * if ([NSApp isOnLeopardOrBetter]) { NSURL *url = [NSURL fileURLWithPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]]; - fNeedSetTimeMachine = CSBackupSetItemExcluded((CFURLRef)url, false, false) != noErr; + CSBackupSetItemExcluded((CFURLRef)url, false, true); } NSString * folder = [self shouldUseIncompleteFolderForName: [self name]] ? fIncompleteFolder : fDownloadFolder; @@ -1680,7 +1671,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * if ([NSApp isOnLeopardOrBetter]) { NSURL *url = [NSURL fileURLWithPath: [folder stringByAppendingPathComponent: [self name]]]; - fNeedSetTimeMachine = CSBackupSetItemExcluded((CFURLRef)url, ![self allDownloaded], false) != noErr; + CSBackupSetItemExcluded((CFURLRef)url, ![self allDownloaded], true); } } @@ -1727,7 +1718,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * if ([NSApp isOnLeopardOrBetter]) { NSURL *url = [NSURL fileURLWithPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]]; - fNeedSetTimeMachine = CSBackupSetItemExcluded((CFURLRef)url, false, false) != noErr; + CSBackupSetItemExcluded((CFURLRef)url, false, true); } fStat = tr_torrentStat(fHandle); @@ -1739,7 +1730,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * if ([NSApp isOnLeopardOrBetter]) { NSURL *url = [NSURL fileURLWithPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]]; - fNeedSetTimeMachine = CSBackupSetItemExcluded((CFURLRef)url, true, false) != noErr; + CSBackupSetItemExcluded((CFURLRef)url, true, true); } [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentRestartedDownloading" object: self];