Permalink
Browse files

Merge pull request #638 from limbo-lab/master

added clearDiskOnCompletion
  • Loading branch information...
2 parents 1b394c1 + 1d8bfa6 commit 657bd816587b894aa83a72f9bc678ac26b6e421d @rs 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 657bd81

Please sign in to comment.