MCPcopy Create free account
hub / github.com/Snapchat/Valdi / initializeBundle

Method initializeBundle

valdi/src/valdi/runtime/Resources/ResourceManager.cpp:160–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160void 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
194void ResourceManager::doInsertImageAssetInBundle(const Ref<Bundle>& bundle,
195 const StringBox& filePath,

Callers

nothing calls this directly

Calls 10

getBundleMethod · 0.80
containsEntryMethod · 0.80
registerManifestMethod · 0.80
assets_sizeMethod · 0.80
has_artifactMethod · 0.80
initWithRemoteArchiveMethod · 0.80
initWithLocalArchiveMethod · 0.80
getNameMethod · 0.45
getEntryMethod · 0.45
has_valueMethod · 0.45

Tested by

no test coverage detected