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
|
* Clear all disk cached images
|
||||||
*/
|
*/
|
||||||
- (void)clearDisk;
|
- (void)clearDisk;
|
||||||
|
- (void)clearDiskOnCompletion:(void (^)())completion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove all expired cached image from disk
|
* Remove all expired cached image from disk
|
||||||
|
|
|
@ -336,12 +336,23 @@ BOOL ImageDataHasPNGPreffix(NSData *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)clearDisk {
|
- (void)clearDisk {
|
||||||
|
[self clearDiskOnCompletion:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)clearDiskOnCompletion:(void (^)())completion
|
||||||
|
{
|
||||||
dispatch_async(self.ioQueue, ^{
|
dispatch_async(self.ioQueue, ^{
|
||||||
[[NSFileManager defaultManager] removeItemAtPath:self.diskCachePath error:nil];
|
[[NSFileManager defaultManager] removeItemAtPath:self.diskCachePath error:nil];
|
||||||
[[NSFileManager defaultManager] createDirectoryAtPath:self.diskCachePath
|
[[NSFileManager defaultManager] createDirectoryAtPath:self.diskCachePath
|
||||||
withIntermediateDirectories:YES
|
withIntermediateDirectories:YES
|
||||||
attributes:nil
|
attributes:nil
|
||||||
error:NULL];
|
error:NULL];
|
||||||
|
|
||||||
|
if (completion) {
|
||||||
|
dispatch_main_sync_safe(^{
|
||||||
|
completion();
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue