MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / get_plugin_info

Method get_plugin_info

plugin_manager/plugin_manager.cpp:118–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118Dictionary PluginManager::get_plugin_info(const String &plugin_name, const Vector<String> &hashes) {
119 Ref<PluginSource> source = get_source(plugin_name);
120 ERR_FAIL_COND_V_MSG(source.is_null(), Dictionary(), "No source found for plugin: " + plugin_name);
121
122 PluginVersion found_version;
123 // First, check all cached PluginVersions for this plugin
124 {
125 MutexLock lock(plugin_version_cache_mutex);
126 String first_version;
127 String replacement_version;
128 for (auto &E : plugin_version_cache) {
129 const PluginVersion &cached_version = E.value;
130
131 // Check if this cached version is for the requested plugin
132 if (cached_version.is_valid() && cached_version.plugin_name == plugin_name) {
133 // Check if any of the hashes match
134 if (cached_version.bin_hashes_match(hashes)) {
135 print_line("Found matching plugin in cache: " + plugin_name + ", version: " + cached_version.release_info.version + ", download url: " + cached_version.release_info.download_url);
136 if (known_bad_plugin_versions.has(plugin_name) && known_bad_plugin_versions[plugin_name].first == cached_version.release_info.version) {
137 first_version = cached_version.release_info.version;
138 replacement_version = known_bad_plugin_versions[plugin_name].second;
139 break;
140 }
141 found_version = cached_version;
142 break;
143 }
144 }
145 }
146 if (!replacement_version.is_empty()) {
147 for (auto &E : plugin_version_cache) {
148 const PluginVersion &cached_version = E.value;
149 if (cached_version.is_valid() && cached_version.plugin_name == plugin_name && cached_version.release_info.version == replacement_version) {
150 print_line("Found known bad plugin version: " + plugin_name + ", version: " + first_version + ", replacing with: " + replacement_version);
151 found_version = cached_version;
152 }
153 }
154 ERR_FAIL_COND_V_MSG(!found_version.is_valid(), Dictionary(), "!!!!!!!!!\nNO REPLACEMENT FOUND\n!!!!!!!!!!!");
155 }
156 }
157 if (found_version.is_valid()) {
158 // get the release info from the source
159 if (source->get_plugin_name() == found_version.release_info.plugin_source) {
160 Error err = OK;
161 auto current_info = source->get_release_info(plugin_name, found_version.release_info.primary_id, found_version.release_info.secondary_id, err);
162 ERR_FAIL_COND_V_MSG(err != OK, found_version.to_json(), vformat("Failed to verify release info for plugin %s primary id %d secondary id %d", plugin_name, found_version.release_info.primary_id, found_version.release_info.secondary_id));
163 if (current_info.is_valid() && current_info == found_version.release_info) {
164 return found_version.to_json();
165 }
166 }
167 // otherwise, we need to find the correct release info
168 print_line(vformat("Cache for plugin %s, version %s does not match current release info, recaching...", plugin_name, found_version.release_info.version));
169 Error err = OK;
170 auto release_infos = source->find_release_infos_by_tag(plugin_name, found_version.release_info.version, err);
171 ERR_FAIL_COND_V_MSG(err != OK, found_version.to_json(), vformat("Failed to find release infos for plugin %s tag %s", plugin_name, found_version.release_info.version));
172 if (!release_infos.is_empty()) {
173 for (auto &current_info : release_infos) {
174 PluginVersion plugin_version = _get_plugin_version_for_current_release_info(current_info, err);
175 ERR_CONTINUE_MSG(err != OK, vformat("Failed to populate plugin version for plugin %s primary id %d secondary id %d", plugin_name, current_info.primary_id, current_info.secondary_id));

Callers

nothing calls this directly

Calls 9

bin_hashes_matchMethod · 0.80
get_cache_keyMethod · 0.80
is_validMethod · 0.45
get_plugin_nameMethod · 0.45
get_release_infoMethod · 0.45
to_jsonMethod · 0.45

Tested by

no test coverage detected