Update last access time of images when loaded from disk.
The OS doesn't automatically bump access time when reading files, so LRU would effectively be equivalent to "least recently downloaded" in SDWebImage.
This commit is contained in:
parent
d5732787b7
commit
63c8d708d0
|
@ -71,13 +71,16 @@ static NSString * const SDDiskCacheExtendedAttributeName = @"com.hackemist.SDDis
|
|||
}
|
||||
NSData *data = [NSData dataWithContentsOfFile:filePath options:self.config.diskCacheReadingOptions error:nil];
|
||||
if (data) {
|
||||
[[NSURL fileURLWithPath:filePath] setResourceValue:[NSDate date] forKey:NSURLContentAccessDateKey error:nil];
|
||||
return data;
|
||||
}
|
||||
|
||||
// fallback because of https://github.com/rs/SDWebImage/pull/976 that added the extension to the disk file name
|
||||
// checking the key with and without the extension
|
||||
data = [NSData dataWithContentsOfFile:filePath.stringByDeletingPathExtension options:self.config.diskCacheReadingOptions error:nil];
|
||||
filePath = filePath.stringByDeletingPathExtension;
|
||||
data = [NSData dataWithContentsOfFile:filePath options:self.config.diskCacheReadingOptions error:nil];
|
||||
if (data) {
|
||||
[[NSURL fileURLWithPath:filePath] setResourceValue:[NSDate date] forKey:NSURLContentAccessDateKey error:nil];
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue