Permalink
Browse files

added clearDiskOnCompletion

  • Loading branch information...
1 parent 10ff189 commit 1d8bfa6064fe05f2435c5d7b2593f566c11be7c6 @cherry-geqi cherry-geqi committed Feb 18, 2014
Showing with 12 additions and 0 deletions.
  1. +1 −0 SDWebImage/SDImageCache.h
  2. +11 −0 SDWebImage/SDImageCache.m
@@ -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
View
@@ -336,12 +336,23 @@ - (void)clearMemory {
}
- (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();
+ });
+ }
});
}

0 comments on commit 1d8bfa6

Please sign in to comment.