Skip to content

Commit

Permalink
Merge pull request #197 from CleverTap/bugfix/SDK-2231/CTLocalDataSto…
Browse files Browse the repository at this point in the history
…re-crash

[SDK-2231] [CTLocalDataStore persistLocalProfileIfRequired] crash
  • Loading branch information
akashvercetti committed Oct 11, 2022
2 parents 1c4b727 + b028a1a commit 72da2c1
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions CleverTapSDK/CTLocalDataStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -625,16 +625,18 @@ - (NSMutableDictionary *)_inflateLocalProfile {
}

- (void)persistLocalProfileIfRequired {
BOOL shouldPersist = NO;
double now = [[[NSDate alloc] init] timeIntervalSince1970];
@synchronized (lastProfilePersistenceTime) {
if (now > (lastProfilePersistenceTime.doubleValue + kProfilePersistenceIntervalSeconds)) {
shouldPersist = YES;
[self runOnBackgroundQueue:^{
BOOL shouldPersist = NO;
double now = [[[NSDate alloc] init] timeIntervalSince1970];
@synchronized (self->lastProfilePersistenceTime) {
if (now > (self->lastProfilePersistenceTime.doubleValue + kProfilePersistenceIntervalSeconds)) {
shouldPersist = YES;
}
}
}
if (shouldPersist) {
[self _persistLocalProfileAsync];
}
if (shouldPersist) {
[self _persistLocalProfileAsync];
}
}];
}

- (void)_persistLocalProfileAsync {
Expand Down

0 comments on commit 72da2c1

Please sign in to comment.