summaryrefslogtreecommitdiff
path: root/src/buildtool/main/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildtool/main/main.cpp')
-rw-r--r--src/buildtool/main/main.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index a3f985b7..5b72b640 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -1209,24 +1209,27 @@ void WriteTargetCacheEntries(
gsl::not_null<IExecutionApi*> const& local_api,
gsl::not_null<IExecutionApi*> const& remote_api) {
auto ts = TaskSystem{jobs};
- TargetCache::Instance().SetLocalApi(local_api);
- TargetCache::Instance().SetRemoteApi(remote_api);
+ auto downloader = [&local_api, &remote_api](auto infos) {
+ return remote_api->RetrieveToCas(infos, local_api);
+ };
for (auto const& [key, target] : cache_targets) {
- ts.QueueTask([&key = key, &target = target, &extra_infos]() {
- if (auto entry =
- TargetCacheEntry::FromTarget(target, extra_infos)) {
- if (not TargetCache::Instance().Store(key, *entry)) {
+ ts.QueueTask(
+ [&key = key, &target = target, &extra_infos, &downloader]() {
+ if (auto entry =
+ TargetCacheEntry::FromTarget(target, extra_infos)) {
+ if (not TargetCache::Instance().Store(
+ key, *entry, downloader)) {
+ Logger::Log(LogLevel::Warning,
+ "Failed writing target cache entry for {}",
+ key.Id().ToString());
+ }
+ }
+ else {
Logger::Log(LogLevel::Warning,
- "Failed writing target cache entry for {}",
+ "Failed creating target cache entry for {}",
key.Id().ToString());
}
- }
- else {
- Logger::Log(LogLevel::Warning,
- "Failed creating target cache entry for {}",
- key.Id().ToString());
- }
- });
+ });
}
}
#endif