| 356 | } |
| 357 | |
| 358 | std::string FindImageFile(const image_source::ImageEntry& image, const std::string& cache_dir, |
| 359 | const std::string& kind) { |
| 360 | for (const auto& file : image.files) { |
| 361 | const auto& name = file.name; |
| 362 | const bool is_kernel = name == "vmlinuz" || name.rfind("vmlinuz", 0) == 0 || name.rfind("Image", 0) == 0; |
| 363 | const bool is_initrd = name.rfind("initrd", 0) == 0 || name.rfind("initramfs", 0) == 0; |
| 364 | const bool is_disk = name.find(".qcow2") != std::string::npos || name.find("rootfs") != std::string::npos; |
| 365 | if ((kind == "kernel" && is_kernel) || (kind == "initrd" && is_initrd) || |
| 366 | (kind == "disk" && is_disk)) { |
| 367 | return (std::filesystem::path(cache_dir) / name).string(); |
| 368 | } |
| 369 | } |
| 370 | return {}; |
| 371 | } |
| 372 | |
| 373 | std::string RandomWsKey() { |
| 374 | static constexpr char chars[] = |