Fix hang in CSBackupSetItemExcluded (#4208)

This commit is contained in:
A Cœur 2022-11-19 22:50:13 +08:00 committed by GitHub
parent d27c4c59ce
commit 292b092f54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 10 deletions

View File

@ -46,7 +46,7 @@ static int const kETAIdleDisplaySec = 2 * 60;
@property(nonatomic) BOOL fResumeOnWake; @property(nonatomic) BOOL fResumeOnWake;
@property(nonatomic) BOOL fTimeMachineExcludeInitialized; @property(nonatomic) dispatch_queue_t timeMachineExcludeQueue;
- (void)renameFinished:(BOOL)success - (void)renameFinished:(BOOL)success
nodes:(NSArray<FileListNode*>*)nodes nodes:(NSArray<FileListNode*>*)nodes
@ -253,12 +253,6 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error** error)
coalesceMask:NSNotificationCoalescingOnName coalesceMask:NSNotificationCoalescingOnName
forModes:nil]; forModes:nil];
} }
//when the torrent is first loaded, update the time machine exclusion
if (!self.fTimeMachineExcludeInitialized)
{
[self updateTimeMachineExclude];
}
} }
- (void)startTransferIgnoringQueue:(BOOL)ignoreQueue - (void)startTransferIgnoringQueue:(BOOL)ignoreQueue
@ -1773,8 +1767,9 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error** error)
name:@"GroupValueRemoved" name:@"GroupValueRemoved"
object:nil]; object:nil];
_fTimeMachineExcludeInitialized = NO; _timeMachineExcludeQueue = dispatch_queue_create("updateTimeMachineExclude", DISPATCH_QUEUE_CONCURRENT);
[self update]; [self update];
[self updateTimeMachineExclude];
return self; return self;
} }
@ -2113,8 +2108,10 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error** error)
NSString* path; NSString* path;
if ((path = self.dataLocation)) if ((path = self.dataLocation))
{ {
CSBackupSetItemExcluded((__bridge CFURLRef)[NSURL fileURLWithPath:path], exclude, false); dispatch_async(_timeMachineExcludeQueue, ^{
self.fTimeMachineExcludeInitialized = YES; CFURLRef url = (__bridge CFURLRef)[NSURL fileURLWithPath:path];
CSBackupSetItemExcluded(url, exclude, false);
});
} }
} }