Skip to content

Crash preventation#4661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Crashlytics/Crashlytics/Controllers/FIRCLSNetworkClient.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -132,12 +132,16 @@ - (BOOL)supportsBackgroundRequests {

- (void)attemptToReconnectBackgroundSessionWithCompletionBlock:(void (^)(void))completionBlock {
if (!self.supportsBackgroundRequests) {
completionBlock();
if (completionBlock) {
completionBlock();
}
return;
}

// This is the absolute minimum necessary. Perhaps we can do better?
[[NSOperationQueue mainQueue] addOperationWithBlock:completionBlock];
if (completionBlock) {
[[NSOperationQueue mainQueue] addOperationWithBlock:completionBlock];
}
}

#pragma mark - API
Expand Down
42 changes: 15 additions & 27 deletions Crashlytics/Crashlytics/Models/FIRCLSFileManager.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -140,8 +140,9 @@ - (void)enumerateFilesInDirectory:(NSString *)directory

extension = [path pathExtension];
fullPath = [directory stringByAppendingPathComponent:path];

block(fullPath, extension);
if (block) {
block(fullPath, extension);
}
}
}

Expand DownExpand Up@@ -176,7 +177,7 @@ - (NSArray *)contentsOfDirectory:(NSString *)path {
[array addObject:filePath];
}];

return array;
return [array copy];
}

#pragma - Properties
Expand DownExpand Up@@ -271,8 +272,9 @@ - (void)enumerateReportsInProcessingDirectoryUsingBlock:(void (^)(FIRCLSInternal
usingBlock:^(NSString *filePath, NSString *extension) {
FIRCLSInternalReport *report =
[FIRCLSInternalReport reportWithPath:filePath];

block(report, filePath);
if (block) {
block(report, filePath);
}
}];
}

Expand DownExpand Up@@ -303,28 +305,14 @@ - (BOOL)removeContentsOfPendingPath {
}

- (BOOL)removeContentsOfAllPaths {
BOOL success = YES;

// We want to call all of these methods, even if some fail, and return
// NO if any fail. This turned out to be slightly tricky to do in more
// compact forms, so I did it the simple but verbose way.

if (![self removeContentsOfProcessingPath]) {
success = NO;
}

if (![self removeContentsOfPendingPath]) {
success = NO;
}

if (![self removeContentsOfDirectoryAtPath:self.preparedPath]) {
success = NO;
}

if (![self removeContentsOfDirectoryAtPath:self.activePath]) {
success = NO;
}

BOOL contentsOfProcessingPathRemoved = [self removeContentsOfProcessingPath];
BOOL contentsOfPendingPathRemoved = [self removeContentsOfPendingPath];
BOOL contentsOfDirectoryAtPreparedPathRemoved =
[self removeContentsOfDirectoryAtPath:self.preparedPath];
BOOL contentsOfDirectoryAtActivePathRemoved =
[self removeContentsOfDirectoryAtPath:self.activePath];
BOOL success = contentsOfProcessingPathRemoved && contentsOfPendingPathRemoved &&
contentsOfDirectoryAtPreparedPathRemoved && contentsOfDirectoryAtActivePathRemoved;
return success;
}

Expand Down
close