Skip to content

Commit

Permalink
Merge pull request SDWebImage#1041 from john-07/master
Browse files Browse the repository at this point in the history
allow override diskCachePath
  • Loading branch information
bpoplauschi committed Mar 19, 2015
2 parents 85dde52 + 6468a92 commit eac0b81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions SDWebImage/SDImageCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot
*/
- (id)initWithNamespace:(NSString *)ns;

-(NSString *)makeDiskCachePath:(NSString*)fullNamespace;

/**
* Add a read-only cache path to search for images pre-cached by SDImageCache
* Useful if you want to bundle pre-loaded images with your app
Expand Down
9 changes: 7 additions & 2 deletions SDWebImage/SDImageCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ - (id)initWithNamespace:(NSString *)ns {
_memCache.name = fullNamespace;

// Init the disk cache
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
_diskCachePath = [paths[0] stringByAppendingPathComponent:fullNamespace];
_diskCachePath = [self makeDiskCachePath:fullNamespace];

// Set decompression to YES
_shouldDecompressImages = YES;
Expand Down Expand Up @@ -147,6 +146,12 @@ - (NSString *)cachedFileNameForKey:(NSString *)key {

#pragma mark ImageCache

// Init the disk cache
-(NSString *)makeDiskCachePath:(NSString*)fullNamespace{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
return [paths[0] stringByAppendingPathComponent:fullNamespace];
}

- (void)storeImage:(UIImage *)image recalculateFromImage:(BOOL)recalculate imageData:(NSData *)imageData forKey:(NSString *)key toDisk:(BOOL)toDisk {
if (!image || !key) {
return;
Expand Down

0 comments on commit eac0b81

Please sign in to comment.