Merge pull request #687 from rokemoon/master
Create NSOperation when start operation.
This commit is contained in:
commit
689586f73a
|
@ -190,7 +190,7 @@ typedef void(^SDWebImageQueryCompletedBlock)(UIImage *image, SDImageCacheType ca
|
||||||
/**
|
/**
|
||||||
* Get the number of images in the disk cache
|
* Get the number of images in the disk cache
|
||||||
*/
|
*/
|
||||||
- (int)getDiskCount;
|
- (NSUInteger)getDiskCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asynchronously calculate the disk cache's size.
|
* Asynchronously calculate the disk cache's size.
|
||||||
|
|
|
@ -265,9 +265,9 @@ BOOL ImageDataHasPNGPreffix(NSData *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(void (^)(UIImage *image, SDImageCacheType cacheType))doneBlock {
|
- (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) {
|
if (!key) {
|
||||||
doneBlock(nil, SDImageCacheTypeNone);
|
doneBlock(nil, SDImageCacheTypeNone);
|
||||||
|
@ -281,6 +281,7 @@ BOOL ImageDataHasPNGPreffix(NSData *data) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSOperation *operation = [NSOperation new];
|
||||||
dispatch_async(self.ioQueue, ^{
|
dispatch_async(self.ioQueue, ^{
|
||||||
if (operation.isCancelled) {
|
if (operation.isCancelled) {
|
||||||
return;
|
return;
|
||||||
|
@ -482,13 +483,11 @@ BOOL ImageDataHasPNGPreffix(NSData *data) {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int)getDiskCount {
|
- (NSUInteger)getDiskCount {
|
||||||
__block int count = 0;
|
__block NSUInteger count = 0;
|
||||||
dispatch_sync(self.ioQueue, ^{
|
dispatch_sync(self.ioQueue, ^{
|
||||||
NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtPath:self.diskCachePath];
|
NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtPath:self.diskCachePath];
|
||||||
for (__unused NSString *fileName in fileEnumerator) {
|
count = [[fileEnumerator allObjects] count];
|
||||||
count += 1;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue