diff options
Diffstat (limited to 'plugins/PluginUpdater/src/Notifications.cpp')
-rw-r--r-- | plugins/PluginUpdater/src/Notifications.cpp | 22 |
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);
|