Skip to content

Commit

Permalink
Exclude files from backup
Browse files Browse the repository at this point in the history
  • Loading branch information
f2prateek committed Jun 29, 2016
1 parent f1e74bc commit 5e4805e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Analytics/Classes/Internal/SEGSegmentIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ - (id)initWithAnalytics:(SEGAnalytics *)analytics
dispatch_sync(dispatch_get_main_queue(), ^{
self.flushTimer = [NSTimer scheduledTimerWithTimeInterval:30.0 target:self selector:@selector(flush) userInfo:nil repeats:YES];
});
[self addSkipBackupAttributeToItemAtPath:self.userIDURL];
[self addSkipBackupAttributeToItemAtPath:self.anonymousIDURL];
[self addSkipBackupAttributeToItemAtPath:self.traitsURL];
[self addSkipBackupAttributeToItemAtPath:self.queueURL];
}
return self;
}
Expand Down Expand Up @@ -504,6 +508,24 @@ - (void)reset
}];
}

- (void)addSkipBackupAttributeToItemAtPath:(NSURL *)url
{
BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:[url path]];
if (!exists) {
return;
}

NSError *error = nil;
BOOL success = [url setResourceValue:[NSNumber numberWithBool:YES]
forKey:NSURLIsExcludedFromBackupKey
error:&error];
if (!success) {
SEGLog(@"Error excluding %@ from backup %@", [url lastPathComponent], error);
}
return;
}


- (void)notifyForName:(NSString *)name userInfo:(id)userInfo
{
dispatch_async(dispatch_get_main_queue(), ^{
Expand Down

0 comments on commit 5e4805e

Please sign in to comment.