Changeset 13419


Ignore:
Timestamp:
Aug 6, 2012, 3:59:07 AM (10 years ago)
Author:
livings124
Message:

#4454 Patch by 0ptional: Time Machine exclusion for partial download does not work on Lion

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Torrent.h

    r13379 r13419  
    5353    BOOL fResumeOnWake;
    5454   
    55     NSString * fTimeMachineExclude;
     55    BOOL fTimeMachineExcludeInitialized;
    5656}
    5757
  • trunk/macosx/Torrent.m

    r13418 r13419  
    4040        groupValue: (NSNumber *) groupValue
    4141        removeWhenFinishSeeding: (NSNumber *) removeWhenFinishSeeding
    42         timeMachineExcludeLocation: (NSString *) timeMachineExclude
    4342        downloadFolder: (NSString *) downloadFolder
    4443        legacyIncompleteFolder: (NSString *) incompleteFolder;
     
    5857- (NSString *) etaString;
    5958
    60 - (void) setTimeMachineExclude: (BOOL) exclude forPath: (NSString *) path;
     59- (void) setTimeMachineExclude: (BOOL) exclude;
    6160
    6261@end
     
    113112            groupValue: nil
    114113            removeWhenFinishSeeding: nil
    115             timeMachineExcludeLocation: nil
    116114            downloadFolder: location
    117115            legacyIncompleteFolder: nil];
     
    130128            groupValue: nil
    131129            removeWhenFinishSeeding: nil
    132             timeMachineExcludeLocation: nil
    133130            downloadFolder: location
    134131            legacyIncompleteFolder: nil];
     
    142139            lib: lib groupValue: nil
    143140            removeWhenFinishSeeding: nil
    144             timeMachineExcludeLocation: nil
    145141            downloadFolder: location legacyIncompleteFolder: nil];
    146142   
     
    157153                groupValue: [history objectForKey: @"GroupValue"]
    158154                removeWhenFinishSeeding: [history objectForKey: @"RemoveWhenFinishSeeding"]
    159                 timeMachineExcludeLocation: [history objectForKey: @"TimeMachineExcludeLocation"]
    160155                downloadFolder: [history objectForKey: @"DownloadFolder"] //upgrading from versions < 1.80
    161156                legacyIncompleteFolder: [[history objectForKey: @"UseIncompleteFolder"] boolValue] //upgrading from versions < 1.80
     
    201196- (NSDictionary *) history
    202197{
    203     NSMutableDictionary * history = [NSMutableDictionary dictionaryWithObjectsAndKeys:
    204                                         [self torrentLocation], @"InternalTorrentPath",
    205                                         [self hashString], @"TorrentHash",
    206                                         [NSNumber numberWithBool: [self isActive]], @"Active",
    207                                         [NSNumber numberWithBool: [self waitingToStart]], @"WaitToStart",
    208                                         [NSNumber numberWithInt: fGroupValue], @"GroupValue",
    209                                         [NSNumber numberWithBool: fRemoveWhenFinishSeeding], @"RemoveWhenFinishSeeding", nil];
    210    
    211     if (fTimeMachineExclude)
    212         [history setObject: fTimeMachineExclude forKey: @"TimeMachineExcludeLocation"];
    213    
    214     return history;
     198    return [NSDictionary dictionaryWithObjectsAndKeys:
     199            [self torrentLocation], @"InternalTorrentPath",
     200            [self hashString], @"TorrentHash",
     201            [NSNumber numberWithBool: [self isActive]], @"Active",
     202            [NSNumber numberWithBool: [self waitingToStart]], @"WaitToStart",
     203            [NSNumber numberWithInt: fGroupValue], @"GroupValue",
     204            [NSNumber numberWithBool: fRemoveWhenFinishSeeding], @"RemoveWhenFinishSeeding", nil];
    215205}
    216206
     
    232222    [fFlatFileList release];
    233223   
    234     [fTimeMachineExclude release];
    235    
    236224    [super dealloc];
    237225}
     
    250238{
    251239    //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     }
     240    [self setTimeMachineExclude: NO];
    258241   
    259242    tr_torrentRemove(fHandle, trashFiles, trashDataFile);
     
    262245- (void) changeDownloadFolderBeforeUsing: (NSString *) folder
    263246{
    264      tr_torrentSetDownloadDir(fHandle, [folder UTF8String]);
    265      [self updateTimeMachineExclude];
     247    //if data existed in original download location, unexclude it before changing the location
     248    [self setTimeMachineExclude: NO];
     249   
     250    tr_torrentSetDownloadDir(fHandle, [folder UTF8String]);
    266251}
    267252
     
    310295        [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateQueue" object: self];
    311296   
    312     //when the data first appears, update time machine exclusion
    313     if (!fTimeMachineExclude)
     297    //when the torrent is first loaded, update the time machine exclusion
     298    if (!fTimeMachineExcludeInitialized)
    314299        [self updateTimeMachineExclude];
    315300}
     
    15481533- (void) updateTimeMachineExclude
    15491534{
    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     }
     1535    [self setTimeMachineExclude: ![self allDownloaded]];
    15701536}
    15711537
     
    16901656        name: @"GroupValueRemoved" object: nil];
    16911657   
    1692     fTimeMachineExclude = [timeMachineExclude retain];
     1658    fTimeMachineExcludeInitialized = NO;
    16931659    [self update];
    16941660   
     
    19281894}
    19291895
    1930 - (void) setTimeMachineExclude: (BOOL) exclude forPath: (NSString *) path
    1931 {
    1932     CSBackupSetItemExcluded((CFURLRef)[NSURL fileURLWithPath: path], exclude, true);
     1896- (void) setTimeMachineExclude: (BOOL) exclude
     1897{
     1898    NSString * path;
     1899    if ((path = [self dataLocation]))
     1900    {
     1901        CSBackupSetItemExcluded((CFURLRef)[NSURL fileURLWithPath: path], exclude, false);
     1902        fTimeMachineExcludeInitialized = YES;
     1903    }
    19331904}
    19341905
Note: See TracChangeset for help on using the changeset viewer.