Skip to content

Commit

Permalink
fix: Synchronize storing of breadcrumbs and events
Browse files Browse the repository at this point in the history
  • Loading branch information
HazAT committed Mar 26, 2018
1 parent 02434cb commit 98842a2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Sources/Sentry/SentryFileManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,23 @@ - (NSString *)storeEvent:(SentryEvent *)event {
}

- (NSString *)storeEvent:(SentryEvent *)event maxCount:(NSUInteger)maxCount {
NSString *result = [self storeDictionary:[event serialize] toPath:self.eventsPath];
[self handleFileManagerLimit:self.eventsPath maxCount:MIN(maxCount, maxEvents)];
return result;
@synchronized (self) {
NSString *result = [self storeDictionary:[event serialize] toPath:self.eventsPath];
[self handleFileManagerLimit:self.eventsPath maxCount:MIN(maxCount, maxEvents)];
return result;
}
}

- (NSString *)storeBreadcrumb:(SentryBreadcrumb *)crumb {
return [self storeBreadcrumb:crumb maxCount:maxBreadcrumbs];
}

- (NSString *)storeBreadcrumb:(SentryBreadcrumb *)crumb maxCount:(NSUInteger)maxCount {
NSString *result = [self storeDictionary:[crumb serialize] toPath:self.breadcrumbsPath];
[self handleFileManagerLimit:self.breadcrumbsPath maxCount:MIN(maxCount, maxBreadcrumbs)];
return result;
@synchronized (self) {
NSString *result = [self storeDictionary:[crumb serialize] toPath:self.breadcrumbsPath];
[self handleFileManagerLimit:self.breadcrumbsPath maxCount:MIN(maxCount, maxBreadcrumbs)];
return result;
}
}

- (NSString *)storeDictionary:(NSDictionary *)dictionary toPath:(NSString *)path {
Expand Down

0 comments on commit 98842a2

Please sign in to comment.