| 210 | } |
| 211 | |
| 212 | bool LoadImageMeta(const std::string& cache_dir, ImageEntry& entry) { |
| 213 | fs::path meta_path = fs::path(cache_dir) / "image.json"; |
| 214 | if (!fs::exists(meta_path)) { |
| 215 | return false; |
| 216 | } |
| 217 | |
| 218 | std::ifstream ifs(meta_path); |
| 219 | if (!ifs) { |
| 220 | return false; |
| 221 | } |
| 222 | |
| 223 | std::string content((std::istreambuf_iterator<char>(ifs)), |
| 224 | std::istreambuf_iterator<char>()); |
| 225 | |
| 226 | auto images = ParseImages("{\"images\":[" + content + "]}"); |
| 227 | if (images.empty()) { |
| 228 | return false; |
| 229 | } |
| 230 | |
| 231 | entry = std::move(images[0]); |
| 232 | return true; |
| 233 | } |
| 234 | |
| 235 | size_t CleanupStaleImageCache(const std::string& images_dir) { |
| 236 | std::error_code ec; |
no test coverage detected