| 361 | } |
| 362 | |
| 363 | void RemoteModuleManager::loadModule(const StringBox& moduleName, |
| 364 | Function<void(Result<Ref<ValdiModuleArchive>>)> completion) { |
| 365 | auto manifest = getRegisteredManifest(moduleName); |
| 366 | if (manifest == nullptr) { |
| 367 | completion(Error(STRING_FORMAT("Module '{}' doesnt have a downloadable manifest registered", moduleName))); |
| 368 | return; |
| 369 | } |
| 370 | |
| 371 | auto url = StringCache::getGlobal().makeString(manifest->pb.artifact().url()); |
| 372 | const auto& sha256Digest = manifest->pb.artifact().sha256digest(); |
| 373 | auto sha256DigestBytesView = |
| 374 | BytesView(manifest, reinterpret_cast<const Byte*>(sha256Digest.data()), sha256Digest.size()); |
| 375 | |
| 376 | auto weakThis = weakRef(this); |
| 377 | _downloader->enqueue(moduleName.prepend("module-"), |
| 378 | url, |
| 379 | _moduleTransformer, |
| 380 | sha256DigestBytesView, |
| 381 | [weakThis, completion = std::move(completion)](auto result, auto /*loadSource*/) { |
| 382 | auto strongThis = weakThis.lock(); |
| 383 | if (strongThis != nullptr) { |
| 384 | strongThis->handleModuleLoadCompleted(result, completion); |
| 385 | } |
| 386 | }); |
| 387 | } |
| 388 | |
| 389 | void RemoteModuleManager::setDecompressionDisabled(bool decompressionDisabled) { |
| 390 | _moduleTransformer.setDecompressionDisabled(decompressionDisabled); |
nothing calls this directly
no test coverage detected