Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.

Calling getResourceValue asynchronously #443

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions Classes/BITHockeyHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,18 @@ void bit_fixBackupAttributeForURL(NSURL *directoryURL) {
}

if (directoryURL) {
NSError *getResourceError = nil;
NSNumber *appSupportDirExcludedValue;

if ([directoryURL getResourceValue:&appSupportDirExcludedValue forKey:NSURLIsExcludedFromBackupKey error:&getResourceError] && appSupportDirExcludedValue) {
NSError *setResourceError = nil;
[directoryURL setResourceValue:@NO forKey:NSURLIsExcludedFromBackupKey error:&setResourceError];
}
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSError *getResourceError = nil;
NSNumber *appSupportDirExcludedValue;
if ([directoryURL getResourceValue:&appSupportDirExcludedValue forKey:NSURLIsExcludedFromBackupKey error:&getResourceError] && appSupportDirExcludedValue) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either log NSError or just pass nil

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please log the error using log level error.

NSError *setResourceError = nil;
if(![directoryURL setResourceValue:@NO forKey:NSURLIsExcludedFromBackupKey error:&setResourceError]) {
BITHockeyLogError(@"ERROR: Error while setting resource value: %@", setResourceError.localizedDescription);
}
} else {
BITHockeyLogError(@"ERROR: Error while retrieving resource value: %@", getResourceError.localizedDescription);
}
});
}
}

Expand Down
21 changes: 13 additions & 8 deletions Support/HockeySDKTests/BITHockeyHelperTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -307,15 +307,20 @@ - (NSURL *)createBackupExcludedTestDirectoryForURL{
}

- (BOOL)excludeAttributeIsSetForURL:(NSURL *)directoryURL {

NSError *getResourceError = nil;
NSNumber *appSupportDirExcludedValue;
if ([directoryURL getResourceValue:&appSupportDirExcludedValue forKey:NSURLIsExcludedFromBackupKey error:&getResourceError] && appSupportDirExcludedValue) {
if ([appSupportDirExcludedValue isEqualToValue:@YES]) {
return YES;
__block BOOL result = NO;
XCTestExpectation *expectation = [self expectationWithDescription:@"wait"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSError *getResourceError = nil;
NSNumber *appSupportDirExcludedValue;
if ([directoryURL getResourceValue:&appSupportDirExcludedValue forKey:NSURLIsExcludedFromBackupKey error:&getResourceError] && appSupportDirExcludedValue) {
if ([appSupportDirExcludedValue isEqualToValue:@YES]) {
result = YES;
}
}
}
return NO;
[expectation fulfill];
});
[self waitForExpectationsWithTimeout:5 handler:nil];
return result;
}

@end