Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #8069 from hansemannn/TIMOB-23141-FIX
Browse files Browse the repository at this point in the history
[TIMOB-23141] iOS: Apply Ti.Filesystem.File.remoteBackup settings recursively
  • Loading branch information
cheekiatng committed Jun 28, 2016
2 parents 6a624cd + 01d0cbd commit 30cd153
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions iphone/Classes/TiFilesystemFileProxy.m
Expand Up @@ -508,20 +508,36 @@ -(NSNumber*)remoteBackup
-(void)setRemoteBackup:(id)value
{
ENSURE_TYPE(value, NSNumber);

BOOL isExcluded = ![TiUtils boolValue:value def:YES];
NSURL *URL= [NSURL fileURLWithPath: [self path]];
NSError *error;

BOOL success = [URL setResourceValue:NUMBOOL(isExcluded)
forKey:NSURLIsExcludedFromBackupKey error:&error];
if (!success) {
[self throwException:@"Error setting remote backup flag:"
subreason:[error localizedDescription]
location:CODELOCATION];
[self addSkipBackupAttributeToFolder:[NSURL URLWithString:[self path]] withFlag:isExcluded];
}

-(void)addSkipBackupAttributeToFolder:(NSURL*)folder withFlag:(BOOL)flag
{
[self addSkipBackupAttributeToItemAtURL:folder withFlag:flag];

NSError* error = nil;
NSArray* folderContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[folder path] error:&error];

for (NSString* item in folderContent) {
[self addSkipBackupAttributeToFolder:[NSURL fileURLWithPath:[folder.path stringByAppendingPathComponent:item]] withFlag:flag];
}
}

-(BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL withFlag:(BOOL)flag
{
NSError *error = nil;
BOOL success = [URL setResourceValue:[NSNumber numberWithBool: flag]
forKey: NSURLIsExcludedFromBackupKey error: &error];

if(!success) {
NSLog(@"[ERROR] Remote-backup status of %@ could not be changed: %@", [URL lastPathComponent], [error localizedDescription]);
}

return success;
}

@end

#endif

0 comments on commit 30cd153

Please sign in to comment.