From e0bb11dee76db814a37ecfb155076169d8780878 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 22 May 2025 16:49:26 +0300 Subject: fixes #1907 (PluginUpdater: move deleting/renaming file rules from plugin to server side) --- plugins/PluginUpdater/src/Utils.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'plugins/PluginUpdater/src/Utils.cpp') diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 5fbf66192d..ecab59c7a0 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -29,7 +29,7 @@ int CompareHashes(const ServListEntry *p1, const ServListEntry *p2) return _wcsicmp(p1->m_name, p2->m_name); } -bool ParseHashes(const wchar_t *pwszUrl, ptrW &baseUrl, SERVLIST &arHashes) +bool ParseHashes(const wchar_t *pwszUrl, ptrW &baseUrl, SERVLIST &arHashes, RENAMETABLE *arRename) { REPLACEVARSARRAY vars[2]; vars[0].key.w = L"platform"; @@ -42,6 +42,9 @@ bool ParseHashes(const wchar_t *pwszUrl, ptrW &baseUrl, SERVLIST &arHashes) baseUrl = Utils_ReplaceVarsW(pwszUrl, 0, vars); + if (arRename) + arRename->destroy(); + // Download version info FILEURL pFileUrl; mir_snwprintf(pFileUrl.wszDownloadURL, L"%s/hashes.zip", baseUrl.get()); @@ -113,6 +116,21 @@ bool ParseHashes(const wchar_t *pwszUrl, ptrW &baseUrl, SERVLIST &arHashes) fclose(fp); DeleteFileW(wszTmpIni); + // building table of rules + mir_snwprintf(wszTmpIni, L"%s\\rules.txt", g_wszTempPath); + if (arRename) { + JSONNode root; + if (file2json(wszTmpIni, root)) + for (auto &it : root["rules"]) { + Utf2T wszName(it.name()); + if (it.isnull()) + arRename->insert(new RenameTableItem(wszName, nullptr)); + else + arRename->insert(new RenameTableItem(wszName, it.as_mstring())); + } + } + DeleteFileW(wszTmpIni); + if (bDoNotSwitchToStable) { g_plugin.setByte(DB_SETTING_DONT_SWITCH_TO_STABLE, 1); // Reset setting if needed -- cgit v1.2.3