Skip to content

Commit b5c4044

Browse files
authored
Gracefully fail rollout write (#12863)
1 parent a2fd744 commit b5c4044

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Crashlytics/Crashlytics/Controllers/FIRCLSRolloutsPersistenceManager.m

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,15 @@ - (void)updateRolloutsStateToPersistenceWithRollouts:(NSData *_Nonnull)rollouts
5858
NSFileHandle *rolloutsFile = [NSFileHandle fileHandleForUpdatingAtPath:rolloutsPath];
5959

6060
dispatch_sync(FIRCLSGetLoggingQueue(), ^{
61-
[rolloutsFile seekToEndOfFile];
62-
[rolloutsFile writeData:rollouts];
63-
NSData *newLineData = [@"\n" dataUsingEncoding:NSUTF8StringEncoding];
64-
[rolloutsFile writeData:newLineData];
61+
@try {
62+
[rolloutsFile seekToEndOfFile];
63+
NSMutableData *rolloutsWithNewLineData = [rollouts mutableCopy];
64+
[rolloutsWithNewLineData appendData:[@"\n" dataUsingEncoding:NSUTF8StringEncoding]];
65+
[rolloutsFile writeData:rolloutsWithNewLineData];
66+
} @catch (NSException *exception) {
67+
FIRCLSDebugLog(@"Failed to write new rollouts. Exception name: %s - message: %s",
68+
exception.name, exception.reason);
69+
}
6570
});
6671
}
6772

0 commit comments

Comments
 (0)