Proper place for the pragma mark and used a function to check for the proper queue
This commit is contained in:
parent
ba88022c30
commit
2fa77435c1
|
@ -136,6 +136,12 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
|
||||||
SDDispatchQueueRelease(_ioQueue);
|
SDDispatchQueueRelease(_ioQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)checkIfQueueIsIOQueue {
|
||||||
|
const char *currentQueueLabel = dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL);
|
||||||
|
const char *ioQueueLabel = dispatch_queue_get_label(self.ioQueue);
|
||||||
|
NSAssert(strcmp(currentQueueLabel, ioQueueLabel) == 0, @"This method should be called from the ioQueue");
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Cache paths
|
#pragma mark - Cache paths
|
||||||
|
|
||||||
- (void)addReadOnlyCachePath:(nonnull NSString *)path {
|
- (void)addReadOnlyCachePath:(nonnull NSString *)path {
|
||||||
|
@ -236,9 +242,7 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *currentQueueLabel = dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL);
|
[self checkIfQueueIsIOQueue];
|
||||||
const char *ioQueueLabel = dispatch_queue_get_label(self.ioQueue);
|
|
||||||
NSAssert(strcmp(currentQueueLabel, ioQueueLabel) == 0, @"This method should be called from the ioQueue");
|
|
||||||
|
|
||||||
if (![_fileManager fileExistsAtPath:_diskCachePath]) {
|
if (![_fileManager fileExistsAtPath:_diskCachePath]) {
|
||||||
[_fileManager createDirectoryAtPath:_diskCachePath withIntermediateDirectories:YES attributes:nil error:NULL];
|
[_fileManager createDirectoryAtPath:_diskCachePath withIntermediateDirectories:YES attributes:nil error:NULL];
|
||||||
|
@ -257,6 +261,8 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - Query and Retrieve Ops
|
||||||
|
|
||||||
- (void)diskImageExistsWithKey:(nullable NSString *)key completion:(nullable SDWebImageCheckCacheCompletionBlock)completionBlock {
|
- (void)diskImageExistsWithKey:(nullable NSString *)key completion:(nullable SDWebImageCheckCacheCompletionBlock)completionBlock {
|
||||||
dispatch_async(_ioQueue, ^{
|
dispatch_async(_ioQueue, ^{
|
||||||
BOOL exists = [_fileManager fileExistsAtPath:[self defaultCachePathForKey:key]];
|
BOOL exists = [_fileManager fileExistsAtPath:[self defaultCachePathForKey:key]];
|
||||||
|
@ -275,8 +281,6 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Query and Retrieve Ops
|
|
||||||
|
|
||||||
- (nullable UIImage *)imageFromMemoryCacheForKey:(nullable NSString *)key {
|
- (nullable UIImage *)imageFromMemoryCacheForKey:(nullable NSString *)key {
|
||||||
return [self.memCache objectForKey:key];
|
return [self.memCache objectForKey:key];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue