disable iCloud backup
This commit is contained in:
parent
c68d585e49
commit
a9ea132874
|
@ -42,6 +42,11 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot
|
||||||
*/
|
*/
|
||||||
@property (assign, nonatomic) BOOL shouldDecompressImages;
|
@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.
|
* The maximum "total cost" of the in-memory image cache. The cost function is the number of pixels held in memory.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -116,6 +116,9 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
|
||||||
// Set decompression to YES
|
// Set decompression to YES
|
||||||
_shouldDecompressImages = YES;
|
_shouldDecompressImages = YES;
|
||||||
|
|
||||||
|
// Disable iCloud
|
||||||
|
_shouldDisableiCloud = YES;
|
||||||
|
|
||||||
dispatch_sync(_ioQueue, ^{
|
dispatch_sync(_ioQueue, ^{
|
||||||
_fileManager = [NSFileManager new];
|
_fileManager = [NSFileManager new];
|
||||||
});
|
});
|
||||||
|
@ -237,7 +240,17 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
|
||||||
[_fileManager createDirectoryAtPath:_diskCachePath withIntermediateDirectories:YES attributes:nil error:NULL];
|
[_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];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue