Skip to content

Commit

Permalink
disable iCloud backup
Browse files Browse the repository at this point in the history
  • Loading branch information
mythodeia committed Jul 15, 2015
1 parent c68d585 commit a9ea132
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions SDWebImage/SDImageCache.h
Expand Up @@ -42,6 +42,11 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot
*/
@property (assign, nonatomic) BOOL shouldDecompressImages;

/**
* disable iCloud backup [defaults to YES]
*/
@property (assign, nonatomic) BOOL shouldDisableiCloud;

/**
* The maximum "total cost" of the in-memory image cache. The cost function is the number of pixels held in memory.
*/
Expand Down
15 changes: 14 additions & 1 deletion SDWebImage/SDImageCache.m
Expand Up @@ -116,6 +116,9 @@ - (id)initWithNamespace:(NSString *)ns diskCacheDirectory:(NSString *)directory
// Set decompression to YES
_shouldDecompressImages = YES;

// Disable iCloud
_shouldDisableiCloud = YES;

dispatch_sync(_ioQueue, ^{
_fileManager = [NSFileManager new];
});
Expand Down Expand Up @@ -237,7 +240,17 @@ - (void)storeImage:(UIImage *)image recalculateFromImage:(BOOL)recalculate image
[_fileManager createDirectoryAtPath:_diskCachePath withIntermediateDirectories:YES attributes:nil error:NULL];
}

[_fileManager createFileAtPath:[self defaultCachePathForKey:key] contents:data attributes:nil];
// get cache Path for image key
NSString *cachePathForKey = [self defaultCachePathForKey:key];
// transform to NSUrl
NSURL *fileURL = [NSURL fileURLWithPath:cachePathForKey];

[_fileManager createFileAtPath:cachePathForKey contents:data attributes:nil];

// disable iCloud backup
if (self.shouldDisableiCloud) {
[fileURL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:nil];
}
}
});
}
Expand Down

0 comments on commit a9ea132

Please sign in to comment.