From 07412b413cebac931bb50e717caf51780c7cc588 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 20 Nov 2017 18:04:15 -0500 Subject: [PATCH] Refresh plugin only if the plugin slug and exact version is not found or does not match --- src/plugin.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/plugin.cpp b/src/plugin.cpp index 374480cd..fbce8f02 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -226,11 +226,22 @@ static int extractZip(const char *filename, const char *dir) { static void refreshPurchase(json_t *pluginJ) { json_t *slugJ = json_object_get(pluginJ, "slug"); if (!slugJ) return; - const char *slug = json_string_value(slugJ); + std::string slug = json_string_value(slugJ); json_t *nameJ = json_object_get(pluginJ, "name"); if (!nameJ) return; - const char *name = json_string_value(nameJ); + std::string name = json_string_value(nameJ); + + json_t *versionJ = json_object_get(pluginJ, "version"); + if (!versionJ) return; + std::string version = json_string_value(versionJ); + + // Check whether the plugin is already loaded + for (Plugin *plugin : gPlugins) { + if (plugin->slug == slug && plugin->version == version) { + return; + } + } // Append token and version to download URL std::string url = gApiHost;