Skip to content

Commit

Permalink
Merge pull request #687 from rokemoon/master
Browse files Browse the repository at this point in the history
Create NSOperation when start operation.
  • Loading branch information
bpoplauschi committed Jun 15, 2014
2 parents e6c0f56 + c285074 commit 689586f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion SDWebImage/SDImageCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ typedef void(^SDWebImageQueryCompletedBlock)(UIImage *image, SDImageCacheType ca
/**
* Get the number of images in the disk cache
*/
- (int)getDiskCount;
- (NSUInteger)getDiskCount;

/**
* Asynchronously calculate the disk cache's size.
Expand Down
15 changes: 7 additions & 8 deletions SDWebImage/SDImageCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ - (UIImage *)scaledImageForKey:(NSString *)key image:(UIImage *)image {
}

- (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(void (^)(UIImage *image, SDImageCacheType cacheType))doneBlock {
NSOperation *operation = [NSOperation new];

if (!doneBlock) return nil;
if (!doneBlock) {
return nil;
}

if (!key) {
doneBlock(nil, SDImageCacheTypeNone);
Expand All @@ -281,6 +281,7 @@ - (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(void (^)(UIImage *im
return nil;
}

NSOperation *operation = [NSOperation new];
dispatch_async(self.ioQueue, ^{
if (operation.isCancelled) {
return;
Expand Down Expand Up @@ -482,13 +483,11 @@ - (NSUInteger)getSize {
return size;
}

- (int)getDiskCount {
__block int count = 0;
- (NSUInteger)getDiskCount {
__block NSUInteger count = 0;
dispatch_sync(self.ioQueue, ^{
NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtPath:self.diskCachePath];
for (__unused NSString *fileName in fileEnumerator) {
count += 1;
}
count = [[fileEnumerator allObjects] count];
});
return count;
}
Expand Down

0 comments on commit 689586f

Please sign in to comment.