From 9e6ac9d1d2a131a60aa1a9894b1e947b1b13b64a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 11 Oct 2023 18:54:41 +0300 Subject: =?UTF-8?q?fixes=20#3708=20(PluginUpdater:=20=D0=B4=D0=BE=D0=B1?= =?UTF-8?q?=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20=D0=B2=20PluginUpdaterFiles=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA=D1=83=20=D0=BC?= =?UTF-8?q?=D0=B0=D1=81=D0=BE=D0=BA)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/PluginUpdater/src/DlgListNew.cpp | 8 +++--- plugins/PluginUpdater/src/DlgUpdate.cpp | 13 ++++++--- plugins/PluginUpdater/src/stdafx.h | 4 +++ plugins/PluginUpdater/src/unzipfile.cpp | 49 ++++++++++++++++++++++++++------ plugins/PluginUpdater/src/version.h | 2 +- 5 files changed, 59 insertions(+), 17 deletions(-) diff --git a/plugins/PluginUpdater/src/DlgListNew.cpp b/plugins/PluginUpdater/src/DlgListNew.cpp index 44fa701c89..82411128bc 100644 --- a/plugins/PluginUpdater/src/DlgListNew.cpp +++ b/plugins/PluginUpdater/src/DlgListNew.cpp @@ -352,7 +352,7 @@ static void ApplyDownloads(void *param) // if we need to escalate priviledges, launch a atub if (PU::PrepareEscalation()) pDlg->Unpack(); - + pDlg->Close(); } @@ -361,7 +361,7 @@ static void __stdcall LaunchListDialog(void *param) (new CMissingPLuginsDlg((OBJLIST *)param))->Show(); } -static FILEINFO* ServerEntryToFileInfo(const ServListEntry &hash, const wchar_t* pwszBaseUrl, const wchar_t* pwszPath) +static FILEINFO* ServerEntryToFileInfo(const ServListEntry &hash, const wchar_t *pwszBaseUrl, const wchar_t *pwszPath) { FILEINFO *FileInfo = new FILEINFO; FileInfo->bDeleteOnly = FALSE; @@ -379,14 +379,14 @@ static FILEINFO* ServerEntryToFileInfo(const ServListEntry &hash, const wchar_t* if (auto *tp = wcsrchr(wszRelFileName, L'.')) *tp = 0; if (auto *tp = wcschr(wszRelFileName, L'\\')) - wcslwr((tp) ? tp+1 : wszRelFileName); + wcslwr((tp) ? tp + 1 : wszRelFileName); mir_snwprintf(FileInfo->File.wszDiskPath, L"%s\\Temp\\%s.zip", g_wszRoot, wszFileName); mir_snwprintf(FileInfo->File.wszDownloadURL, L"%s/%s.zip", pwszBaseUrl, wszRelFileName); for (auto *tp = wcschr(FileInfo->File.wszDownloadURL, '\\'); tp != nullptr; tp = wcschr(tp, '\\')) *tp++ = '/'; FileInfo->File.CRCsum = hash.m_crc; - + // Load list of checked Plugins from database Netlib_LogfW(g_hNetlibUser, L"File %s found", FileInfo->wszOldName); FileInfo->bEnabled = db_get_b(0, DB_MODULE_NEW_FILES, _T2A(FileInfo->wszOldName)) != 0; diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index 492a3fdfdb..a88a14292b 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -81,6 +81,8 @@ class CUpdateDLg : public CDlgBase Netlib_CloseHandle(nlc); // 3) Unpack all zips + InitMasks(); + uint32_t dwErrorCode; for (auto &it : todo) { if (it->bEnabled) { @@ -117,6 +119,7 @@ LBL_Error: } } + UninitMasks(); RemoveBackupFolders(); Skin_PlaySound("updatecompleted"); @@ -392,6 +395,8 @@ static void DlgUpdateSilent(void *param) } // 3) Unpack all zips + InitMasks(); + uint32_t dwErrorCode; for (auto &it : UpdateFiles) { if (it->bEnabled) { @@ -425,7 +430,8 @@ LBL_Error: } } } - + + UninitMasks(); RemoveBackupFolders(); delete &UpdateFiles; @@ -619,7 +625,7 @@ static int ScanFolder(const wchar_t *pwszFolder, size_t cbBaseLen, const wchar_t int count = 0; MFilePath wszBuf(pwszFolder); - for (auto &ff: wszBuf.search()) { + for (auto &ff : wszBuf.search()) { TFileName wszNewName; if (ff.isDir()) { @@ -698,8 +704,7 @@ static int ScanFolder(const wchar_t *pwszFolder, size_t cbBaseLen, const wchar_t } else Netlib_LogfW(g_hNetlibUser, L"File %s: Update available", ff.getPath()); } - __except (EXCEPTION_EXECUTE_HANDLER) - { + __except (EXCEPTION_EXECUTE_HANDLER) { // smth went wrong, reload a file from scratch } } diff --git a/plugins/PluginUpdater/src/stdafx.h b/plugins/PluginUpdater/src/stdafx.h index c321f133f4..3248123ed1 100644 --- a/plugins/PluginUpdater/src/stdafx.h +++ b/plugins/PluginUpdater/src/stdafx.h @@ -25,6 +25,7 @@ Boston, MA 02111-1307, USA. #include #include #include +#include #include // Miranda header files @@ -240,6 +241,9 @@ void InitEvents(); void InitListNew(); void UnloadListNew(); +void InitMasks(); +void UninitMasks(); + void DoRestart(void); void CALLBACK RestartPrompt(void *); diff --git a/plugins/PluginUpdater/src/unzipfile.cpp b/plugins/PluginUpdater/src/unzipfile.cpp index 2f9133c929..56457b07ee 100644 --- a/plugins/PluginUpdater/src/unzipfile.cpp +++ b/plugins/PluginUpdater/src/unzipfile.cpp @@ -21,16 +21,49 @@ Boston, MA 02111-1307, USA. #define DATA_BUF_SIZE (4 * 1024 * 1024) +static LIST sttMasks(100); + +static int sttEnumProc(const char *szSetting, void *) +{ + if (1 != db_get_b(0, DB_MODULE_FILES, szSetting, 1)) + sttMasks.insert(mir_strdup(szSetting)); + return 0; +} + +static bool IsFilteredFile(const char *szFileName) +{ + char *tmp = NEWSTR_ALLOCA(szFileName); + _strlwr(tmp); + + for (auto &it: sttMasks) + if (wildcmp(tmp, it)) + return true; + + return false; +} + +void InitMasks() +{ + db_enum_settings(0, sttEnumProc, DB_MODULE_FILES); +} + +void UninitMasks() +{ + for (auto &it : sttMasks) + mir_free(it); + sttMasks.destroy(); +} + static void PrepareFileName(wchar_t *dest, size_t destSize, const wchar_t *pwszPath, const wchar_t *pwszFileName) { mir_snwprintf(dest, destSize, L"%s\\%s", pwszPath, pwszFileName); for (wchar_t *p = dest; *p; ++p) if (*p == '/') - *p = '\\'; + *p = '\\'; } -int extractCurrentFile(unzFile uf, wchar_t *pwszDestPath, wchar_t *pwszBackPath, bool ch) +int extractCurrentFile(unzFile uf, wchar_t *pwszDestPath, wchar_t *pwszBackPath, bool bCheckFilter) { unz_file_info64 file_info; char filename[MAX_PATH]; @@ -40,12 +73,12 @@ int extractCurrentFile(unzFile uf, wchar_t *pwszDestPath, wchar_t *pwszBackPath, if (err != UNZ_OK) return err; - for (char *p = strchr(filename, '/'); p; p = strchr(p+1, '/')) + for (char *p = strchr(filename, '/'); p; p = strchr(p + 1, '/')) *p = '\\'; - + // This is because there may be more then one file in a single zip // So we need to check each file - if (ch && 1 != db_get_b(0, DB_MODULE_FILES, _strlwr(ptrA(mir_strdup(filename))), 1)) + if (bCheckFilter && IsFilteredFile(filename)) return UNZ_OK; TFileName wszDestFile, wszBackFile; @@ -109,17 +142,17 @@ int extractCurrentFile(unzFile uf, wchar_t *pwszDestPath, wchar_t *pwszBackPath, return err; } -int unzip(const wchar_t *pwszZipFile, wchar_t *pwszDestPath, wchar_t *pwszBackPath,bool ch) +int unzip(const wchar_t *pwszZipFile, wchar_t *pwszDestPath, wchar_t *pwszBackPath, bool ch) { int iErrorCode = 0; zlib_filefunc64_def ffunc; fill_fopen64_filefunc(&ffunc); - + unzFile uf = unzOpen2_64(pwszZipFile, &ffunc); if (uf) { do { - if (int err = extractCurrentFile(uf, pwszDestPath, pwszBackPath,ch)) + if (int err = extractCurrentFile(uf, pwszDestPath, pwszBackPath, ch)) iErrorCode = err; } while (unzGoToNextFile(uf) == UNZ_OK); diff --git a/plugins/PluginUpdater/src/version.h b/plugins/PluginUpdater/src/version.h index 8269e41d35..33f60eec94 100644 --- a/plugins/PluginUpdater/src/version.h +++ b/plugins/PluginUpdater/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 2 #define __RELEASE_NUM 1 -#define __BUILD_NUM 6 +#define __BUILD_NUM 7 #include -- cgit v1.2.3