Merge pull request #638 from limbo-lab/master
added clearDiskOnCompletion
This commit is contained in:
commit
657bd81658
|
@ -142,6 +142,7 @@ typedef NS_ENUM(NSInteger, SDImageCacheType) {
|
|||
* Clear all disk cached images
|
||||
*/
|
||||
- (void)clearDisk;
|
||||
- (void)clearDiskOnCompletion:(void (^)())completion;
|
||||
|
||||
/**
|
||||
* Remove all expired cached image from disk
|
||||
|
|
|
@ -336,12 +336,23 @@ BOOL ImageDataHasPNGPreffix(NSData *data) {
|
|||
}
|
||||
|
||||
- (void)clearDisk {
|
||||
[self clearDiskOnCompletion:nil];
|
||||
}
|
||||
|
||||
- (void)clearDiskOnCompletion:(void (^)())completion
|
||||
{
|
||||
dispatch_async(self.ioQueue, ^{
|
||||
[[NSFileManager defaultManager] removeItemAtPath:self.diskCachePath error:nil];
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:self.diskCachePath
|
||||
withIntermediateDirectories:YES
|
||||
attributes:nil
|
||||
error:NULL];
|
||||
|
||||
if (completion) {
|
||||
dispatch_main_sync_safe(^{
|
||||
completion();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue