Team lead wants to exclude some files in documents storage class from backup.
My argument that those probably belong to NSCachesDirectory is in vain.
Moreover setting exclusion attribute like so
+ (BOOL)kit_addSkipBackupAttributeToURL:(NSURL *)url
{
if (![[NSFileManager defaultManager] fileExistsAtPath:url.path]) {
return NO;
}
NSError *error = nil;
NSNumber *value = nil;
BOOL success = [url getResourceValue:&value forKey:NSURLIsExcludedFromBackupKey error:&error];
if (value.boolValue == YES) {
NSLog(@"ALREADY Excluded %@ from backup", [url absoluteString]);
return YES;
}
success = [url setResourceValue:[NSNumber numberWithBool:YES]
forKey:NSURLIsExcludedFromBackupKey
error:&error];
if (!success){
NSLog(@"Error excluding %@ from backup: %@", [url lastPathComponent], error);
}
success = [url getResourceValue:&value
forKey:NSURLIsExcludedFromBackupKey
error:&error];
NSAssert(success, @"The backup exclusion attribute did not stick");
NSLog(@"Excluded %@ from backup", [url absoluteString]);
return success;
}
does not trip but listing the directory later on using ls -la@ {directoryname} does not show that attribute. Somehow it fell off.
They stick in Library/Cache though.
Thoughts on fitness of such a usage of backup exclusion attribute in documents domain?
Recognized by Mobile Development Collective