MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / BuildCheckedDownloadTasks

Function BuildCheckedDownloadTasks

engine/Poseidon/UI/OptionsUIApp.cpp:1381–1409  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

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.
1382static 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.

Callers 1

OnButtonClickedMethod · 0.85

Calls 6

BareModIdFunction · 0.85
ModInstallDirFunction · 0.85
SizeMethod · 0.45
GetLengthMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected