summaryrefslogtreecommitdiff
path: root/plugins/PluginUpdater/src/Notifications.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-10-10 16:11:36 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-10-10 16:11:36 +0000
commit12be1d94b988efbaee17bc1cdf1667c870d1a53b (patch)
treea9392e334a3d88b4159efbc9eb3e66f859506ab7 /plugins/PluginUpdater/src/Notifications.cpp
parentfbe102bea6ca57970d1de4a2c6cc349d3f6ff71d (diff)
intermediate variant of Updater without problems with core
git-svn-id: http://svn.miranda-ng.org/main/trunk@1865 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/PluginUpdater/src/Notifications.cpp')
-rw-r--r--plugins/PluginUpdater/src/Notifications.cpp22
1 files changed, 16 insertions, 6 deletions
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);