Skip to content
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

Exclude files from backup #567

Merged
merged 1 commit into from
Jun 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about anonymousIdURL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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