Download tasks for every ticked-but-not-downloaded row that carries a URL. Each task downloads the zstd-wrapped mod artifact next to its install dir then unpacks it into / (so GetModInstallStatus sees it installed). Returns true if any.
| 1379 | |
| 1380 | // libcurl download bridged to the agnostic DownloadFileFn. The C progress |
| 1381 | // callback can't carry captures, so onBytes is reached through a void* context. |
| 1382 | static DownloadFileFn MakeMasterServerTransport(std::string proxy) |
| 1383 | { |
| 1384 | return [proxy](const DownloadTask& task, const std::function<void(int64_t, int64_t)>& onBytes, |
| 1385 | const std::function<bool()>& cancelled, std::string& error) -> bool |
| 1386 | { |
| 1387 | struct Ctx |
| 1388 | { |
| 1389 | const std::function<void(int64_t, int64_t)>* cb; |
| 1390 | const std::function<bool()>* cancelled; |
| 1391 | } ctx{&onBytes, &cancelled}; |
| 1392 | const bool ok = DownloadMasterServerServiceFile( |
| 1393 | task.url.c_str(), proxy.empty() ? nullptr : proxy.c_str(), task.destPath.c_str(), &ctx, |
| 1394 | [](void* instance, int64_t received, int64_t total) |
| 1395 | { |
| 1396 | auto* c = static_cast<Ctx*>(instance); |
| 1397 | if (c != nullptr && c->cb != nullptr && *c->cb) |
| 1398 | (*c->cb)(received, total); |
| 1399 | }, |
| 1400 | [](void* instance) -> bool |
| 1401 | { |
| 1402 | // Abort the libcurl transfer promptly when the worker is cancelled. |
| 1403 | auto* c = static_cast<Ctx*>(instance); |
| 1404 | return c != nullptr && c->cancelled != nullptr && *c->cancelled && (*c->cancelled)(); |
| 1405 | }); |
| 1406 | if (!ok) |
| 1407 | error = "download failed"; |
| 1408 | return ok; |
| 1409 | }; |
| 1410 | } |
| 1411 | |
| 1412 | // Bare mod id (no leading '@') — ModInstallDir/GetModInstallStatus prepend it. |
no test coverage detected