| 1019 | |
| 1020 | |
| 1021 | Option<shared_ptr<FetcherProcess::Cache::Entry>> |
| 1022 | FetcherProcess::Cache::get( |
| 1023 | const Option<string>& user, |
| 1024 | const string& uri) |
| 1025 | { |
| 1026 | const string key = cacheKey(user, uri); |
| 1027 | |
| 1028 | Option<shared_ptr<Entry>> entry = table.get(key); |
| 1029 | if (entry.isSome()) { |
| 1030 | // The FetcherProcess will always remove a failed download |
| 1031 | // synchronously after marking this future as failed. |
| 1032 | CHECK(!entry.get()->completion().isFailed()); |
| 1033 | |
| 1034 | // Validate the cache file, if it has been downloaded. |
| 1035 | if (entry.get()->completion().isReady()) { |
| 1036 | Try<Nothing> validation = validate(entry.get()); |
| 1037 | if (validation.isError()) { |
| 1038 | LOG(WARNING) << "Validation failed: '" + validation.error() + |
| 1039 | "'. Removing cache entry..."; |
| 1040 | |
| 1041 | remove(entry.get()); |
| 1042 | return None(); |
| 1043 | } |
| 1044 | } |
| 1045 | |
| 1046 | // Refresh the cache entry by moving it to the back of lruSortedEntries. |
| 1047 | lruSortedEntries.remove(entry.get()); |
| 1048 | lruSortedEntries.push_back(entry.get()); |
| 1049 | } |
| 1050 | |
| 1051 | return entry; |
| 1052 | } |
| 1053 | |
| 1054 | |
| 1055 | bool FetcherProcess::Cache::contains( |
no test coverage detected