Changed: Rerun installer from TEMP under Windows, see #279

This commit is contained in:
kervala 2016-08-14 13:35:46 +02:00
parent 67d4877889
commit 9993eb3ed7
4 changed files with 43 additions and 21 deletions

View file

@ -722,11 +722,28 @@ bool CConfigFile::shouldCreateMenuShortcut() const
return !shortcut.isEmpty() && !NLMISC::CFile::isExists(qToUtf8(shortcut)); return !shortcut.isEmpty() && !NLMISC::CFile::isExists(qToUtf8(shortcut));
} }
QString CConfigFile::getInstallerFullPath() const QString CConfigFile::getInstallerCurrentFilePath() const
{ {
// installer is always run from TEMP under Windows
return QApplication::applicationFilePath();
}
QString CConfigFile::getInstallerCurrentDirPath() const
{
// installer is always run from TEMP under Windows
return QApplication::applicationDirPath(); return QApplication::applicationDirPath();
} }
QString CConfigFile::getInstallerOriginalFilePath() const
{
return getInstallerOriginalDirPath() + "/" + QFileInfo(QApplication::applicationFilePath()).fileName();
}
QString CConfigFile::getInstallerOriginalDirPath() const
{
return m_installationDirectory;
}
QString CConfigFile::getInstallerMenuLinkFullPath() const QString CConfigFile::getInstallerMenuLinkFullPath() const
{ {
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32

View file

@ -113,7 +113,11 @@ public:
QString getClientArch() const; QString getClientArch() const;
QString getInstallerFullPath() const; QString getInstallerCurrentFilePath() const;
QString getInstallerCurrentDirPath() const;
QString getInstallerOriginalFilePath() const;
QString getInstallerOriginalDirPath() const;
QString getInstallerMenuLinkFullPath() const; QString getInstallerMenuLinkFullPath() const;
QStringList getInstallerRequiredFiles() const; QStringList getInstallerRequiredFiles() const;

View file

@ -120,6 +120,24 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
#if defined(Q_OS_WIN) && !defined(_DEBUG)
// under Windows, Ryzom Installer should always be copied in TEMP directory
QString tempPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
// check if launched from TEMP directory
if (step == Done && QApplication::applicationDirPath() != tempPath)
{
// copy installer and required files to TEMP directory
if (copyInstallerFiles(config.getInstallerRequiredFiles(), tempPath))
{
QString tempFile = tempPath + "/" + QFileInfo(QApplication::applicationFilePath()).fileName();
// launch copy in TEMP directory with same arguments
if (QProcess::startDetached(tempFile, QApplication::arguments())) return 0;
}
}
#endif
// use product name from ryzom_installer.ini // use product name from ryzom_installer.ini
if (!config.getProductName().isEmpty()) QApplication::setApplicationName(config.getProductName()); if (!config.getProductName().isEmpty()) QApplication::setApplicationName(config.getProductName());
@ -141,23 +159,6 @@ int main(int argc, char *argv[])
if (parser.isSet(uninstallOption)) if (parser.isSet(uninstallOption))
{ {
#if defined(Q_OS_WIN) && !defined(_DEBUG)
QString tempPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
// check if launched from TEMP directory
if (QApplication::applicationDirPath() != tempPath)
{
// copy installer and required files to TEMP directory
if (copyInstallerFiles(config.getInstallerRequiredFiles(), tempPath))
{
QString tempFile = tempPath + "/" + QFileInfo(QApplication::applicationFilePath()).fileName();
// launch copy in TEMP directory with same arguments
if (QProcess::startDetached(tempFile, QApplication::arguments())) return 0;
}
}
#endif
SComponents components; SComponents components;
// add all servers by default // add all servers by default

View file

@ -1135,7 +1135,7 @@ void COperationDialog::deleteComponentsInstaller()
dir.removeRecursively(); dir.removeRecursively();
} }
path = config->getInstallerFullPath(); path = config->getInstallerOriginalDirPath();
QStringList files = config->getInstallerRequiredFiles(); QStringList files = config->getInstallerRequiredFiles();
foreach(const QString &file, files) foreach(const QString &file, files)
@ -1143,7 +1143,7 @@ void COperationDialog::deleteComponentsInstaller()
QString fullPath = path + "/" + file; QString fullPath = path + "/" + file;
// delete file // delete file
if (!QFile::remove(fullPath)) if (QFile::exists(fullPath) && !QFile::remove(fullPath))
{ {
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
// under Windows, a running executable is locked, so we need to delete it later // under Windows, a running executable is locked, so we need to delete it later