| 167 | } |
| 168 | |
| 169 | void HttpHandler::HandleSteamCacheFile(http::web_request &req, http::web_response &rep) { |
| 170 | std::string_view target = req.target(); |
| 171 | std::string_view query = req.query(); |
| 172 | LOGI("target: {}, query: {}", target, query); |
| 173 | std::string prefix = R"(/steam/cache/)"; |
| 174 | if (!target.starts_with(prefix)) { |
| 175 | return; |
| 176 | } |
| 177 | std::string steam_id = std::string(target).substr(prefix.size(), target.size()); |
| 178 | LOGI("Steam id: {}", steam_id); |
| 179 | |
| 180 | auto steam_manager = context_->GetSteamManager(); |
| 181 | if (!steam_manager) { |
| 182 | return; |
| 183 | } |
| 184 | auto image_cache_path = steam_manager->GetSteamImageCachePath(); |
| 185 | std::string from_cover_path = std::format("{}/{}/library_600x900.jpg", image_cache_path, steam_id); |
| 186 | LOGI("cover path: {}", from_cover_path); |
| 187 | |
| 188 | std::string steam_cover_folder_path = this->context_->GetCurrentExeFolder() + "/resources/steam_covers"; |
| 189 | FolderUtil::CreateDir(steam_cover_folder_path); |
| 190 | std::string target_cover_name = std::format("{}_library_600x900.jpg", steam_id); |
| 191 | std::string target_cover_path = std::format("{}/{}", steam_cover_folder_path, target_cover_name); |
| 192 | FileUtil::CopyFileExt(from_cover_path, target_cover_path, false); |
| 193 | rep.fill_file(std::format("/resources/steam_covers/{}", target_cover_name)); |
| 194 | } |
| 195 | |
| 196 | // impl |
| 197 |
no test coverage detected