Add utility function to snoop the file cache

This commit is contained in:
Henrik Rydgård committed 2026-03-09 10:40:51 +01:00
1 parent 9373791bc4
commit 8c8dd0f0d0
2 files changed
+8

No files matched your search

+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);
+1
View File
@@ -132,6 +132,7 @@ public:
}
Path UrlToCachePath(const std::string_view url);
bool ReadFileFromCache(std::string_view url, std::string *data);
private:
std::vector<std::shared_ptr<Request>> downloads_;