@@ -71,13 +71,16 @@ - (NSData *)dataForKey:(NSString *)key {
71
71
}
72
72
NSData *data = [NSData dataWithContentsOfFile: filePath options: self .config.diskCacheReadingOptions error: nil ];
73
73
if (data) {
74
+ [[NSURL fileURLWithPath: filePath] setResourceValue: [NSDate date ] forKey: NSURLContentAccessDateKey error: nil ];
74
75
return data;
75
76
}
76
77
77
78
// fallback because of https://github.com/rs/SDWebImage/pull/976 that added the extension to the disk file name
78
79
// checking the key with and without the extension
79
- data = [NSData dataWithContentsOfFile: filePath.stringByDeletingPathExtension options: self .config.diskCacheReadingOptions error: nil ];
80
+ filePath = filePath.stringByDeletingPathExtension ;
81
+ data = [NSData dataWithContentsOfFile: filePath options: self .config.diskCacheReadingOptions error: nil ];
80
82
if (data) {
83
+ [[NSURL fileURLWithPath: filePath] setResourceValue: [NSDate date ] forKey: NSURLContentAccessDateKey error: nil ];
81
84
return data;
82
85
}
83
86
@@ -149,11 +152,8 @@ - (void)removeExpiredData {
149
152
NSURL *diskCacheURL = [NSURL fileURLWithPath: self .diskCachePath isDirectory: YES ];
150
153
151
154
// Compute content date key to be used for tests
152
- NSURLResourceKey cacheContentDateKey = NSURLContentModificationDateKey ;
155
+ NSURLResourceKey cacheContentDateKey;
153
156
switch (self.config .diskCacheExpireType ) {
154
- case SDImageCacheConfigExpireTypeAccessDate:
155
- cacheContentDateKey = NSURLContentAccessDateKey ;
156
- break ;
157
157
case SDImageCacheConfigExpireTypeModificationDate:
158
158
cacheContentDateKey = NSURLContentModificationDateKey ;
159
159
break ;
@@ -163,7 +163,9 @@ - (void)removeExpiredData {
163
163
case SDImageCacheConfigExpireTypeChangeDate:
164
164
cacheContentDateKey = NSURLAttributeModificationDateKey ;
165
165
break ;
166
+ case SDImageCacheConfigExpireTypeAccessDate:
166
167
default :
168
+ cacheContentDateKey = NSURLContentAccessDateKey ;
167
169
break ;
168
170
}
169
171
0 commit comments