From 66b2934da83933b5292495025355721466378f91 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 24 May 2016 21:45:44 +0200 Subject: [PATCH] wxUpdCheckThread::DownloadUpdatePackage() does the file-existence check before calculating hash, to avoid unnecessary warning in the log --- Updater/src/chkthread.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Updater/src/chkthread.cpp b/Updater/src/chkthread.cpp index 3862db6..5720ebc 100644 --- a/Updater/src/chkthread.cpp +++ b/Updater/src/chkthread.cpp @@ -394,18 +394,20 @@ bool wxUpdCheckThread::ReadUpdatePackageMeta() bool wxUpdCheckThread::DownloadUpdatePackage() { - // Calculate file hash (if exists). - wxCryptoHashSHA1 ch(*m_cs); - if (ch.HashFile(m_fileName)) { - wxMemoryBuffer buf; - ch.GetValue(buf); + if (wxFileExists(m_fileName)) { + // Calculate file hash. + wxCryptoHashSHA1 ch(*m_cs); + if (ch.HashFile(m_fileName)) { + wxMemoryBuffer buf; + ch.GetValue(buf); - if (buf.GetDataLen() == m_hash.GetDataLen() && - memcmp(buf.GetData(), m_hash.GetData(), buf.GetDataLen()) == 0) - { - // Update package file exists and its hash is correct. - wxLogStatus(_("Update package file already downloaded.")); - return true; + if (buf.GetDataLen() == m_hash.GetDataLen() && + memcmp(buf.GetData(), m_hash.GetData(), buf.GetDataLen()) == 0) + { + // Update package file exists and its hash is correct. + wxLogStatus(_("Update package file already downloaded.")); + return true; + } } }