Add utility function to snoop the file cache

This commit is contained in:
Henrik Rydgård
2026-03-09 10:40:51 +01:00
parent 9373791bc4
commit 8c8dd0f0d0
2 changed files with 8 additions and 0 deletions
+7
View File
@@ -71,6 +71,13 @@ static std::shared_ptr<Request> 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<Request> RequestManager::StartDownload(std::string_view url, const Path &outfile, RequestFlags flags, const char *acceptMime, std::string_view name, std::function<void(Request &)> callback) {
const bool enableCache = !cacheDir_.empty() && (flags & RequestFlags::Cached24H);