mirror of
https://github.com/transmission/transmission
synced 2025-03-12 07:03:44 +00:00
move time machine code into its own function
This commit is contained in:
parent
d2ff4d99f3
commit
c4cba5ad2a
1 changed files with 14 additions and 31 deletions
|
@ -55,6 +55,8 @@ static int static_lastid = 0;
|
|||
|
||||
- (void) trashFile: (NSString *) path;
|
||||
|
||||
- (void) setTimeMachineExclude: (BOOL) exclude forPath: (NSString *) path;
|
||||
|
||||
@end
|
||||
|
||||
void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * torrentData)
|
||||
|
@ -181,11 +183,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
- (void) closeRemoveTorrent
|
||||
{
|
||||
//allow the file to be index by Time Machine
|
||||
if ([NSApp isOnLeopardOrBetter])
|
||||
{
|
||||
NSURL *url = [NSURL fileURLWithPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]];
|
||||
CSBackupSetItemExcluded((CFURLRef)url, false, true);
|
||||
}
|
||||
[self setTimeMachineExclude: NO forPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]];
|
||||
|
||||
tr_torrentRemoveSaved(fHandle);
|
||||
tr_torrentClose(fHandle);
|
||||
|
@ -1566,11 +1564,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
[self update];
|
||||
|
||||
//mark incomplete files to be ignored by Time Machine
|
||||
if ([NSApp isOnLeopardOrBetter])
|
||||
{
|
||||
NSURL *url = [NSURL fileURLWithPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]];
|
||||
CSBackupSetItemExcluded((CFURLRef)url, ![self allDownloaded], true);
|
||||
}
|
||||
[self setTimeMachineExclude: ![self allDownloaded] forPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -1664,21 +1658,12 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
- (void) updateDownloadFolder
|
||||
{
|
||||
//remove old Time Machine location
|
||||
if ([NSApp isOnLeopardOrBetter])
|
||||
{
|
||||
NSURL *url = [NSURL fileURLWithPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]];
|
||||
CSBackupSetItemExcluded((CFURLRef)url, false, true);
|
||||
}
|
||||
[self setTimeMachineExclude: NO forPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]];
|
||||
|
||||
NSString * folder = [self shouldUseIncompleteFolderForName: [self name]] ? fIncompleteFolder : fDownloadFolder;
|
||||
tr_torrentSetFolder(fHandle, [folder UTF8String]);
|
||||
|
||||
//update Time Machine location
|
||||
if ([NSApp isOnLeopardOrBetter])
|
||||
{
|
||||
NSURL *url = [NSURL fileURLWithPath: [folder stringByAppendingPathComponent: [self name]]];
|
||||
CSBackupSetItemExcluded((CFURLRef)url, ![self allDownloaded], true);
|
||||
}
|
||||
[self setTimeMachineExclude: ![self allDownloaded] forPath: [folder stringByAppendingPathComponent: [self name]]];
|
||||
}
|
||||
|
||||
//status has been retained
|
||||
|
@ -1721,11 +1706,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
fDateCompleted = [[NSDate alloc] init];
|
||||
|
||||
//allow to be backed up by Time Machine
|
||||
if ([NSApp isOnLeopardOrBetter])
|
||||
{
|
||||
NSURL *url = [NSURL fileURLWithPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]];
|
||||
CSBackupSetItemExcluded((CFURLRef)url, false, true);
|
||||
}
|
||||
[self setTimeMachineExclude: NO forPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]];
|
||||
|
||||
fStat = tr_torrentStat(fHandle);
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self];
|
||||
|
@ -1733,11 +1714,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
|
||||
case TR_CP_INCOMPLETE:
|
||||
//do not allow to be backed up by Time Machine
|
||||
if ([NSApp isOnLeopardOrBetter])
|
||||
{
|
||||
NSURL *url = [NSURL fileURLWithPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]];
|
||||
CSBackupSetItemExcluded((CFURLRef)url, true, true);
|
||||
}
|
||||
[self setTimeMachineExclude: YES forPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentRestartedDownloading" object: self];
|
||||
break;
|
||||
|
@ -1789,4 +1766,10 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
}
|
||||
}
|
||||
|
||||
- (void) setTimeMachineExclude: (BOOL) exclude forPath: (NSString *) path
|
||||
{
|
||||
if ([NSApp isOnLeopardOrBetter])
|
||||
CSBackupSetItemExcluded((CFURLRef)[NSURL fileURLWithPath: path], exclude, true);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Add table
Reference in a new issue