From 12be1d94b988efbaee17bc1cdf1667c870d1a53b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 10 Oct 2012 16:11:36 +0000 Subject: intermediate variant of Updater without problems with core git-svn-id: http://svn.miranda-ng.org/main/trunk@1865 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/PluginUpdater/src/Notifications.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'plugins/PluginUpdater/src/Notifications.cpp') diff --git a/plugins/PluginUpdater/src/Notifications.cpp b/plugins/PluginUpdater/src/Notifications.cpp index aad66b965e..7e30ad5e85 100644 --- a/plugins/PluginUpdater/src/Notifications.cpp +++ b/plugins/PluginUpdater/src/Notifications.cpp @@ -278,16 +278,26 @@ static void ApplyUpdates(void *param) if ( !todo[i].enabled) continue; + TCHAR tszBackFile[MAX_PATH]; FILEINFO& p = todo[i]; - if (p.bDeleteOnly) { // delete only + if (p.bDeleteOnly) { // we need only to backup the old file TCHAR *ptszRelPath = p.tszNewName + _tcslen(tszMirandaPath) + 1; - TCHAR tszBackFile[MAX_PATH]; mir_sntprintf(tszBackFile, SIZEOF(tszBackFile), _T("%s\\%s"), tszFileBack, ptszRelPath); - DeleteFile(tszBackFile); - MoveFile(p.tszNewName, tszBackFile); + BackupFile(p.tszNewName, tszBackFile); + continue; + } + + // if file name differs, we also need to backup the old file here + // otherwise it would be replaced by unzip + if ( _tcsicmp(p.tszOldName, p.tszNewName)) { + TCHAR tszSrcPath[MAX_PATH]; + mir_sntprintf(tszSrcPath, SIZEOF(tszSrcPath), _T("%s\\%s"), tszMirandaPath, p.tszOldName); + mir_sntprintf(tszBackFile, SIZEOF(tszBackFile), _T("%s\\%s"), tszFileBack, p.tszOldName); + BackupFile(tszSrcPath, tszBackFile); } - else if ( unzip(p.tszOldName, p.File.tszDiskPath, tszMirandaPath, tszFileBack)) - DeleteFile(p.File.tszDiskPath); + + if ( unzip(p.File.tszDiskPath, tszMirandaPath, tszFileBack)) + DeleteFile(p.File.tszDiskPath); // remove .zip after successful update } DBWriteContactSettingByte(NULL, MODNAME, "RestartCount", 2); -- cgit v1.2.3