From 271999e98fc7ba52ce13988b2edb3416ca5e5fe0 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 20 Sep 2016 18:34:59 +0200 Subject: [PATCH 1/2] Changed: Use a temporary file to check if we're uninstalling old client, see #279 --HG-- branch : develop --- .../client/ryzom_installer/src/configfile.cpp | 26 +++++++++++++++---- .../client/ryzom_installer/src/configfile.h | 1 - 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index f23976cd9..fea558af4 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -27,8 +27,7 @@ CConfigFile *CConfigFile::s_instance = NULL; CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_version(-1), - m_defaultServerIndex(0), m_defaultProfileIndex(0), m_use64BitsClient(false), m_shouldUninstallOldClient(true), - m_uninstallingOldClient(false) + m_defaultServerIndex(0), m_defaultProfileIndex(0), m_use64BitsClient(false), m_shouldUninstallOldClient(true) { s_instance = this; @@ -464,12 +463,29 @@ void CConfigFile::setShouldUninstallOldClient(bool on) bool CConfigFile::uninstallingOldClient() const { - return m_uninstallingOldClient; + return QFile::exists(getInstallationDirectory() + "/ryzom_installer_uninstalling_old_client"); } void CConfigFile::setUninstallingOldClient(bool on) { - m_uninstallingOldClient = on; + QString filename = getInstallationDirectory() + "/ryzom_installer_uninstalling_old_client"; + + if (on) + { + // writing a file to avoid asking several times when relaunching installer + QFile file(filename); + + if (file.open(QFile::WriteOnly)) + { + file.write("empty"); + file.close(); + } + } + else + { + // deleting the temporary file + if (QFile::exists(filename)) QFile::remove(filename); + } } QString CConfigFile::expandVariables(const QString &str) const @@ -983,7 +999,7 @@ OperationStep CConfigFile::getInstallNextStep() const if (!settings.contains("InstallLocation")) return CreateAddRemoveEntry; #endif - if (!m_uninstallingOldClient && m_shouldUninstallOldClient && !getSrcServerDirectory().isEmpty() && QFile::exists(getSrcServerDirectory() + "/Uninstall.exe")) + if (!uninstallingOldClient() && m_shouldUninstallOldClient && !getSrcServerDirectory().isEmpty() && QFile::exists(getSrcServerDirectory() + "/Uninstall.exe")) { return UninstallOldClient; } diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.h b/code/ryzom/tools/client/ryzom_installer/src/configfile.h index 998565dda..ecad07af3 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h @@ -152,7 +152,6 @@ private: QString m_srcDirectory; bool m_use64BitsClient; bool m_shouldUninstallOldClient; - bool m_uninstallingOldClient; QString m_language; QString m_defaultConfigPath; From e4d3407be5ec2452890c0a8cef7095f67ebf011f Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 20 Sep 2016 18:35:31 +0200 Subject: [PATCH 2/2] Changed: Fix the temporary directory, see #279 --HG-- branch : develop --- code/ryzom/tools/client/ryzom_installer/src/main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/main.cpp b/code/ryzom/tools/client/ryzom_installer/src/main.cpp index 9bbb26e50..3902296ec 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/main.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/main.cpp @@ -161,13 +161,16 @@ int main(int argc, char *argv[]) foreach(const QString &dir, dirs) { - QDir(dir).removeRecursively(); + // delete each directory + QDir dirToRemove(tempDir); + dirToRemove.cd(dir); + dirToRemove.removeRecursively(); } tempPath += QString("/ryzom_installer_%1").arg(QDateTime::currentMSecsSinceEpoch()); // copy installer and required files to TEMP directory - if (copyInstallerFiles(config.getInstallerRequiredFiles(), tempPath)) + if (QDir().mkdir(tempPath) && copyInstallerFiles(config.getInstallerRequiredFiles(), tempPath)) { QString tempFile = tempPath + "/" + QFileInfo(QApplication::applicationFilePath()).fileName();