Merge pull request #687 from rokemoon/master

Create NSOperation when start operation.
This commit is contained in:
Bogdan Poplauschi 2014-06-15 22:38:07 +03:00
commit 689586f73a
2 changed files with 8 additions and 9 deletions

View File

@ -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.

View File

@ -265,9 +265,9 @@ BOOL ImageDataHasPNGPreffix(NSData *data) {
}
- (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);
@ -281,6 +281,7 @@ BOOL ImageDataHasPNGPreffix(NSData *data) {
return nil;
}
NSOperation *operation = [NSOperation new];
dispatch_async(self.ioQueue, ^{
if (operation.isCancelled) {
return;
@ -482,13 +483,11 @@ BOOL ImageDataHasPNGPreffix(NSData *data) {
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;
}