From 8cfd26f78b30de78726291de367fc52907b848ca Mon Sep 17 00:00:00 2001 From: Olivier Poitrey Date: Tue, 12 Mar 2013 19:26:53 +0100 Subject: [PATCH] Disable duplicate disk cache prevention with SDWebImageRefreshCached to handle 302 caching correctly See https://github.com/rs/SDWebImage/pull/326#issuecomment-14791505 for more info --- Examples/SDWebImage Demo/MasterViewController.m | 5 +++-- SDWebImage/SDWebImageManager.m | 7 ------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Examples/SDWebImage Demo/MasterViewController.m b/Examples/SDWebImage Demo/MasterViewController.m index 6c0a14e..8d7edba 100644 --- a/Examples/SDWebImage Demo/MasterViewController.m +++ b/Examples/SDWebImage Demo/MasterViewController.m @@ -30,7 +30,7 @@ target:self action:@selector(flushCache)]; _objects = [NSArray arrayWithObjects: - @"http://static2.dmcdn.net/static/video/451/838/44838154:jpeg_preview_small.jpg?20120509163826", + @"https://graph.facebook.com/olivier.poitrey/picture?height=200&width=200", @"http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.jpg?20120509154705", @"http://static2.dmcdn.net/static/video/629/228/44822926:jpeg_preview_small.jpg?20120509181018", @"http://static2.dmcdn.net/static/video/116/367/44763611:jpeg_preview_small.jpg?20120509101749", @@ -371,8 +371,9 @@ } cell.textLabel.text = [NSString stringWithFormat:@"Image #%d", indexPath.row]; + cell.imageView.contentMode = UIViewContentModeScaleAspectFill; [cell.imageView setImageWithURL:[NSURL URLWithString:[_objects objectAtIndex:indexPath.row]] - placeholderImage:[UIImage imageNamed:@"placeholder"]]; + placeholderImage:[UIImage imageNamed:@"placeholder"] options:indexPath.row == 0 ? SDWebImageRefreshCached : 0]; return cell; } diff --git a/SDWebImage/SDWebImageManager.m b/SDWebImage/SDWebImageManager.m index e731296..c73593b 100644 --- a/SDWebImage/SDWebImageManager.m +++ b/SDWebImage/SDWebImageManager.m @@ -137,13 +137,6 @@ { BOOL cacheOnDisk = !(options & SDWebImageCacheMemoryOnly); - if (options & SDWebImageRefreshCached) - { - // When SDWebImageRefreshCached option is enabled, the disk caching relies on NSURLCache one. - // We thus fork SDWebImage cache to be disabled so we don't duplicate the required storage space for nothing. - cacheOnDisk = NO; - } - if (options & SDWebImageRefreshCached && image && !downloadedImage) { // Image refresh hit the NSURLCache cache, do not call the completion block