From 87304cbad54fc2ad312aba343f0b2b583c5d5650 Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 22 Sep 2016 18:11:47 +0200 Subject: [PATCH] Changed: Implements shouldCopyInstaller() based on version from executable, see #279 --- .../client/ryzom_installer/src/configfile.cpp | 38 ++++++++++--------- .../client/ryzom_installer/src/configfile.h | 1 + 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 10ea322a2..38c945ade 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -749,6 +749,26 @@ bool CConfigFile::shouldCreateMenuShortcut() const return !shortcut.isEmpty() && !NLMISC::CFile::isExists(qToUtf8(shortcut)); } +bool CConfigFile::shouldCopyInstaller() const +{ + const CProfile &p = getProfile(); + const CServer &s = getServer(p.server); + + QString installerDst = getInstallationDirectory() + "/" + s.installerFilename; + + // if installer not found in installation directory, extract it from BNP + if (!QFile::exists(installerDst)) return true; + + QString installedVersion = getVersionFromExecutable(installerDst); + QString newVersion = QApplication::applicationVersion(); + + QVersionNumber installedVer = QVersionNumber::fromString(installedVersion); + QVersionNumber newVer = QVersionNumber::fromString(newVersion); + + // if version is greater, copy it + return newVer > installedVer; +} + QString CConfigFile::getInstallerCurrentFilePath() const { // installer is always run from TEMP under Windows @@ -955,23 +975,7 @@ OperationStep CConfigFile::getInstallNextStep() const } } - QString installerDst = getInstallationDirectory() + "/" + server.installerFilename; - - // if installer not found in installation directory, extract it from BNP - if (QFile::exists(installerDst)) - { - QString installerSrc = getInstallerCurrentFilePath(); - - // copy it too if destination one if older than new one - uint64 srcDate = QFileInfo(installerSrc).lastModified().toTime_t(); - uint64 dstDate = QFileInfo(installerDst).lastModified().toTime_t(); - - if (srcDate > dstDate) return CopyInstaller; - } - else - { - return CopyInstaller; - } + if (shouldCopyInstaller()) return CopyInstaller; // no default profile if (profile.id.isEmpty()) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.h b/code/ryzom/tools/client/ryzom_installer/src/configfile.h index 70ca6a6a0..a279e6d7a 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h @@ -103,6 +103,7 @@ public: bool foundTemporaryFiles(const QString &directory) const; bool shouldCreateDesktopShortcut() const; bool shouldCreateMenuShortcut() const; + bool shouldCopyInstaller() const; // installation choices bool use64BitsClient() const;