| 158 | } |
| 159 | |
| 160 | void ResourceManager::initializeBundle(BundleInitializer& bundleInitializer, Ref<ValdiModuleArchive> moduleArchive) { |
| 161 | static auto kDownloadManifestName = STRING_LITERAL("download_manifest"); |
| 162 | |
| 163 | const auto& bundle = bundleInitializer.getBundle(); |
| 164 | const auto& bundleName = bundle->getName(); |
| 165 | |
| 166 | if (moduleArchive->containsEntry(kDownloadManifestName)) { |
| 167 | // This is a downlodable module |
| 168 | auto entry = moduleArchive->getEntry(kDownloadManifestName); |
| 169 | SC_ASSERT(entry.has_value(), "Unable to retrieve module entry"); |
| 170 | auto manifest = makeShared<DownloadableModuleManifestWrapper>(); |
| 171 | |
| 172 | if (!manifest->pb.ParseFromArray(entry->data, static_cast<int>(entry->size))) { |
| 173 | VALDI_ERROR(_logger, "Invalid download manifest in module '{}'", bundleName); |
| 174 | initializeBundle(bundleInitializer, makeShared<ValdiModuleArchive>()); |
| 175 | return; |
| 176 | } |
| 177 | |
| 178 | _remoteModuleManager->registerManifest(bundleName, manifest); |
| 179 | |
| 180 | auto hasRemoteAssets = manifest->pb.assets_size() > 0; |
| 181 | |
| 182 | if (manifest->pb.has_artifact()) { |
| 183 | // This is a remote module |
| 184 | bundleInitializer.initWithRemoteArchive(hasRemoteAssets); |
| 185 | } else { |
| 186 | bundleInitializer.initWithLocalArchive(std::move(moduleArchive), hasRemoteAssets); |
| 187 | } |
| 188 | } else { |
| 189 | // This is a regular module |
| 190 | bundleInitializer.initWithLocalArchive(std::move(moduleArchive), false); |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | void ResourceManager::doInsertImageAssetInBundle(const Ref<Bundle>& bundle, |
| 195 | const StringBox& filePath, |
nothing calls this directly
no test coverage detected