summaryrefslogtreecommitdiff
path: root/plugins/PluginUpdater
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2014-05-04 20:13:20 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2014-05-04 20:13:20 +0000
commitc12a8920b8e6c8cc3b4773eef51e05f9be1ff73c (patch)
tree2e4e27b70c32bda6bf7081d7d293bb13ab04fc2b /plugins/PluginUpdater
parent1853c052443ef58a98c849a44f87cb31ab20f96d (diff)
minor performance improvements
git-svn-id: http://svn.miranda-ng.org/main/trunk@9126 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/PluginUpdater')
-rw-r--r--plugins/PluginUpdater/src/DlgUpdate.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp
index 09b9933d22..a0909607df 100644
--- a/plugins/PluginUpdater/src/DlgUpdate.cpp
+++ b/plugins/PluginUpdater/src/DlgUpdate.cpp
@@ -442,12 +442,12 @@ static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const
TCHAR tszNewName[MAX_PATH];
if (!CheckFileRename(ffd.cFileName, tszNewName)) {
if (level == 0)
- _tcscpy(tszNewName, ffd.cFileName);
+ _tcsncpy(tszNewName, ffd.cFileName, MAX_PATH);
else
mir_sntprintf(tszNewName, SIZEOF(tszNewName), _T("%s\\%s"), tszFolder+cbBaseLen, ffd.cFileName);
}
- bool bHasNewVersion = false;
+ bool bHasNewVersion = true;
TCHAR *ptszUrl;
int MyCRC = 0;
mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s\\%s"), tszFolder, ffd.cFileName);
@@ -470,23 +470,24 @@ static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const
}
ptszUrl = item->m_name;
-
- char szMyHash[33];
- __try {
- CalculateModuleHash(tszBuf, szMyHash);
- bHasNewVersion = opts.bForceRedownload ? true : strcmp(szMyHash, item->m_szHash) != 0;
- }
- __except(EXCEPTION_EXECUTE_HANDLER) {
- ZeroMemory(szMyHash, 0);
- bHasNewVersion = true; // smth went wrong, reload a file from scratch
+ // No need to hash a file if we are forcing a redownload anyway
+ if (!opts.bForceRedownload) {
+ // try to hash the file
+ char szMyHash[33];
+ __try {
+ CalculateModuleHash(tszBuf, szMyHash);
+ bHasNewVersion = strcmp(szMyHash, item->m_szHash) != 0;
+ }
+ __except(EXCEPTION_EXECUTE_HANDLER) {
+ ZeroMemory(szMyHash, 0);
+ // smth went wrong, reload a file from scratch
+ }
}
MyCRC = item->m_crc;
}
- else { // file was marked for deletion, add it to the list anyway
- bHasNewVersion = true;
+ else // file was marked for deletion, add it to the list anyway
ptszUrl = _T("");
- }
// Compare versions
if (bHasNewVersion) { // Yeah, we've got new version.