mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 20:35:36 +00:00
(hopefully) improve and streamline time machine code
This commit is contained in:
@@ -71,8 +71,6 @@ typedef enum
|
||||
int fOrderValue, fGroupValue;
|
||||
|
||||
NSDictionary * fQuickPauseDict;
|
||||
|
||||
BOOL fNeedSetTimeMachine;
|
||||
}
|
||||
|
||||
- (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (torrentFileState) torrentDelete
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user