Changed: Implements shouldCopyInstaller() based on version from executable, see #279

This commit is contained in:
kervala 2016-09-22 18:11:47 +02:00
parent 05058eecc8
commit 7813cdc6d9
2 changed files with 22 additions and 17 deletions

View file

@ -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())

View file

@ -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;