Ticket #4454: transmission.diff

File transmission.diff, 8.0 KB (added by 0ptional, 9 years ago)
  • macosx/Torrent.h

     
    5252   
    5353    BOOL fResumeOnWake;
    5454   
    55     NSString * fTimeMachineExclude;
     55    BOOL fTimeMachineExcludeInitialized;
    5656}
    5757
    5858- (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (BOOL) torrentDelete
     
    236236- (NSInteger) stalledMinutes;
    237237- (BOOL) isStalled;
    238238
    239 - (void) updateTimeMachineExclude;
    240 
    241239- (NSInteger) stateSortKey;
    242240- (NSString *) trackerSortKey;
    243241
  • macosx/Torrent.m

     
    3939        magnetAddress: (NSString *) magnetAddress lib: (tr_session *) lib
    4040        groupValue: (NSNumber *) groupValue
    4141        removeWhenFinishSeeding: (NSNumber *) removeWhenFinishSeeding
    42         timeMachineExcludeLocation: (NSString *) timeMachineExclude
     42        timeMachineExcludeInitialized: (BOOL) timeMachineExcludeInitialized
    4343        downloadFolder: (NSString *) downloadFolder
    4444        legacyIncompleteFolder: (NSString *) incompleteFolder;
    4545
     
    5757- (BOOL) shouldShowEta;
    5858- (NSString *) etaString;
    5959
    60 - (void) setTimeMachineExclude: (BOOL) exclude forPath: (NSString *) path;
     60- (void) setTimeMachineExclude: (BOOL) exclude;
    6161
    6262@end
    6363
     
    112112    self = [self initWithPath: path hash: nil torrentStruct: NULL magnetAddress: nil lib: lib
    113113            groupValue: nil
    114114            removeWhenFinishSeeding: nil
    115             timeMachineExcludeLocation: nil
     115            timeMachineExcludeInitialized: NO
    116116            downloadFolder: location
    117117            legacyIncompleteFolder: nil];
    118118   
     
    129129    self = [self initWithPath: nil hash: nil torrentStruct: torrentStruct magnetAddress: nil lib: lib
    130130            groupValue: nil
    131131            removeWhenFinishSeeding: nil
    132             timeMachineExcludeLocation: nil
     132            timeMachineExcludeInitialized: NO
    133133            downloadFolder: location
    134134            legacyIncompleteFolder: nil];
    135135   
     
    141141    self = [self initWithPath: nil hash: nil torrentStruct: nil magnetAddress: address
    142142            lib: lib groupValue: nil
    143143            removeWhenFinishSeeding: nil
    144             timeMachineExcludeLocation: nil
     144            timeMachineExcludeInitialized: NO
    145145            downloadFolder: location legacyIncompleteFolder: nil];
    146146   
    147147    return self;
     
    156156                lib: lib
    157157                groupValue: [history objectForKey: @"GroupValue"]
    158158                removeWhenFinishSeeding: [history objectForKey: @"RemoveWhenFinishSeeding"]
    159                 timeMachineExcludeLocation: [history objectForKey: @"TimeMachineExcludeLocation"]
     159                timeMachineExcludeInitialized: YES
    160160                downloadFolder: [history objectForKey: @"DownloadFolder"] //upgrading from versions < 1.80
    161161                legacyIncompleteFolder: [[history objectForKey: @"UseIncompleteFolder"] boolValue] //upgrading from versions < 1.80
    162162                                        ? [history objectForKey: @"IncompleteFolder"] : nil];
     
    208208                                        [NSNumber numberWithInt: fGroupValue], @"GroupValue",
    209209                                        [NSNumber numberWithBool: fRemoveWhenFinishSeeding], @"RemoveWhenFinishSeeding", nil];
    210210   
    211     if (fTimeMachineExclude)
    212         [history setObject: fTimeMachineExclude forKey: @"TimeMachineExcludeLocation"];
    213    
    214211    return history;
    215212}
    216213
     
    230227   
    231228    [fFileList release];
    232229    [fFlatFileList release];
    233    
    234     [fTimeMachineExclude release];
    235    
     230       
    236231    [super dealloc];
    237232}
    238233
     
    249244- (void) closeRemoveTorrent: (BOOL) trashFiles
    250245{
    251246    //allow the file to be indexed by Time Machine
    252     if (fTimeMachineExclude)
    253     {
    254         [self setTimeMachineExclude: NO forPath: fTimeMachineExclude];
    255         [fTimeMachineExclude release];
    256         fTimeMachineExclude = nil;
    257     }
     247    [self setTimeMachineExclude: NO];
    258248   
    259249    tr_torrentRemove(fHandle, trashFiles, trashDataFile);
    260250}
     
    262252- (void) changeDownloadFolderBeforeUsing: (NSString *) folder
    263253{
    264254     tr_torrentSetDownloadDir(fHandle, [folder UTF8String]);
    265      [self updateTimeMachineExclude];
    266255}
    267256
    268257- (NSString *) currentDirectory
     
    310299        [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateQueue" object: self];
    311300   
    312301    //when the data first appears, update time machine exclusion
    313     if (!fTimeMachineExclude)
    314         [self updateTimeMachineExclude];
     302    if (!fTimeMachineExcludeInitialized)
     303        [self setTimeMachineExclude: YES];
     304   
    315305}
    316306
    317307- (void) startTransferIgnoringQueue: (BOOL) ignoreQueue
     
    563553        [alert runModal];
    564554        [alert release];
    565555    }
    566    
    567     [self updateTimeMachineExclude];
    568556}
    569557
    570558- (void) copyTorrentFileTo: (NSString *) path
     
    15451533    return fStat->isStalled;
    15461534}
    15471535
    1548 - (void) updateTimeMachineExclude
    1549 {
    1550     NSString * currentLocation = ![self allDownloaded] ? [self dataLocation] : nil;
    1551    
    1552     //return if the locations are the same
    1553     if (fTimeMachineExclude && currentLocation && [fTimeMachineExclude isEqualToString: currentLocation])
    1554         return;
    1555    
    1556     //remove old location...
    1557     if (fTimeMachineExclude)
    1558     {
    1559         [self setTimeMachineExclude: NO forPath: fTimeMachineExclude];
    1560         [fTimeMachineExclude release];
    1561         fTimeMachineExclude = nil;
    1562     }
    1563    
    1564     //...set new location
    1565     if (currentLocation)
    1566     {
    1567         [self setTimeMachineExclude: YES forPath: currentLocation];
    1568         fTimeMachineExclude = [currentLocation retain];
    1569     }
    1570 }
    1571 
    15721536- (NSInteger) stateSortKey
    15731537{
    15741538    if (![self isActive]) //paused
     
    16211585        magnetAddress: (NSString *) magnetAddress lib: (tr_session *) lib
    16221586        groupValue: (NSNumber *) groupValue
    16231587        removeWhenFinishSeeding: (NSNumber *) removeWhenFinishSeeding
    1624         timeMachineExcludeLocation: (NSString *) timeMachineExclude
     1588        timeMachineExcludeInitialized: (BOOL) timeMachineExcludeInitialized
    16251589        downloadFolder: (NSString *) downloadFolder
    16261590        legacyIncompleteFolder: (NSString *) incompleteFolder
    16271591{
     
    16891653    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(checkGroupValueForRemoval:)
    16901654        name: @"GroupValueRemoved" object: nil];
    16911655   
    1692     fTimeMachineExclude = [timeMachineExclude retain];
     1656    fTimeMachineExcludeInitialized = timeMachineExcludeInitialized;
    16931657    [self update];
    16941658   
    16951659    return self;
     
    18491813            else
    18501814                NSLog(@"Could not find file to quarantine: %@", dataLocation);
    18511815           
     1816            [self setTimeMachineExclude: NO];
    18521817            break;
    18531818       
    18541819        case TR_LEECH:
    18551820            [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentRestartedDownloading" object: self];
     1821            [self setTimeMachineExclude: YES];
    18561822            break;
    18571823    }
    18581824    [statusInfo release];
    18591825   
    18601826    [self update];
    1861     [self updateTimeMachineExclude];
    18621827}
    18631828
    18641829- (void) ratioLimitHit
     
    19281893    return idleString;
    19291894}
    19301895
    1931 - (void) setTimeMachineExclude: (BOOL) exclude forPath: (NSString *) path
     1896- (void) setTimeMachineExclude: (BOOL) exclude
    19321897{
    1933     CSBackupSetItemExcluded((CFURLRef)[NSURL fileURLWithPath: path], exclude, true);
     1898    NSString * path;
     1899    if ((path = [self dataLocation]))
     1900    {
     1901        CSBackupSetItemExcluded((CFURLRef)[NSURL fileURLWithPath: path], exclude, false);
     1902        fTimeMachineExcludeInitialized = YES;
     1903    }
    19341904}
    19351905
    19361906@end
  • macosx/Controller.m

     
    47954795- (void) rpcMovedTorrent: (Torrent *) torrent
    47964796{
    47974797    [torrent update];
    4798     [torrent updateTimeMachineExclude];
    47994798   
    48004799    if ([[fTableView selectedTorrents] containsObject: torrent])
    48014800        [fInfoController updateInfoStats];