(hopefully) improve and streamline time machine code

This commit is contained in:
Mitchell Livingston 2008-01-05 04:46:18 +00:00
parent 87baf39a8e
commit cf4566eccb
2 changed files with 5 additions and 16 deletions

View File

@ -71,8 +71,6 @@ typedef enum
int fOrderValue, fGroupValue;
NSDictionary * fQuickPauseDict;
BOOL fNeedSetTimeMachine;
}
- (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (torrentFileState) torrentDelete

View File

@ -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];