diff --git a/Common/Net/HTTPRequest.cpp b/Common/Net/HTTPRequest.cpp index fbd4a1c4df..f8f154aef1 100644 --- a/Common/Net/HTTPRequest.cpp +++ b/Common/Net/HTTPRequest.cpp @@ -71,6 +71,13 @@ static std::shared_ptr CreateRequest(RequestMethod method, std::string_ } } +// Compatible with StartDownload +// Synchronous (no callback). +bool RequestManager::ReadFileFromCache(std::string_view url, std::string *data) { + Path cacheFile = UrlToCachePath(url); + return File::ReadBinaryFileToString(cacheFile, data); +} + std::shared_ptr RequestManager::StartDownload(std::string_view url, const Path &outfile, RequestFlags flags, const char *acceptMime, std::string_view name, std::function callback) { const bool enableCache = !cacheDir_.empty() && (flags & RequestFlags::Cached24H); diff --git a/Common/Net/HTTPRequest.h b/Common/Net/HTTPRequest.h index 3886e69a1a..ab7607cd51 100644 --- a/Common/Net/HTTPRequest.h +++ b/Common/Net/HTTPRequest.h @@ -132,6 +132,7 @@ public: } Path UrlToCachePath(const std::string_view url); + bool ReadFileFromCache(std::string_view url, std::string *data); private: std::vector> downloads_;