old mode 100755
new mode 100644
| | |
| | | |
| | | @end |
| | | |
| | | |
| | | @implementation AFImageDownloader |
| | | |
| | | + (NSURLCache *)defaultURLCache { |
| | | |
| | | // It's been discovered that a crash will occur on certain versions |
| | | // of iOS if you customize the cache. |
| | | // |
| | | // More info can be found here: https://devforums.apple.com/message/1102182#1102182 |
| | | // |
| | | // When iOS 7 support is dropped, this should be modified to use |
| | | // NSProcessInfo methods instead. |
| | | if ([[[UIDevice currentDevice] systemVersion] compare:@"8.2" options:NSNumericSearch] == NSOrderedAscending) { |
| | | return [NSURLCache sharedURLCache]; |
| | | } |
| | | return [[NSURLCache alloc] initWithMemoryCapacity:20 * 1024 * 1024 |
| | | diskCapacity:150 * 1024 * 1024 |
| | | diskPath:@"com.alamofire.imagedownloader"]; |
| | |
| | | |
| | | - (instancetype)init { |
| | | NSURLSessionConfiguration *defaultConfiguration = [self.class defaultURLSessionConfiguration]; |
| | | AFHTTPSessionManager *sessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:defaultConfiguration]; |
| | | return [self initWithSessionConfiguration:defaultConfiguration]; |
| | | } |
| | | |
| | | - (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { |
| | | AFHTTPSessionManager *sessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:configuration]; |
| | | sessionManager.responseSerializer = [AFImageResponseSerializer serializer]; |
| | | |
| | | return [self initWithSessionManager:sessionManager |
| | |
| | | |
| | | createdTask = [self.sessionManager |
| | | dataTaskWithRequest:request |
| | | uploadProgress:nil |
| | | downloadProgress:nil |
| | | completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) { |
| | | dispatch_async(self.responseQueue, ^{ |
| | | __strong __typeof__(weakSelf) strongSelf = weakSelf; |
| | | AFImageDownloaderMergedTask *mergedTask = self.mergedTasks[URLIdentifier]; |
| | | AFImageDownloaderMergedTask *mergedTask = strongSelf.mergedTasks[URLIdentifier]; |
| | | if ([mergedTask.identifier isEqual:mergedTaskIdentifier]) { |
| | | mergedTask = [strongSelf safelyRemoveMergedTaskWithURLIdentifier:URLIdentifier]; |
| | | if (error) { |
| | |
| | | } |
| | | } |
| | | } else { |
| | | [strongSelf.imageCache addImage:responseObject forRequest:request withAdditionalIdentifier:nil]; |
| | | if ([strongSelf.imageCache shouldCacheImage:responseObject forRequest:request withAdditionalIdentifier:nil]) { |
| | | [strongSelf.imageCache addImage:responseObject forRequest:request withAdditionalIdentifier:nil]; |
| | | } |
| | | |
| | | for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) { |
| | | if (handler.successBlock) { |