Changed: Clean files
--HG-- branch : feature-ryzom-installer
This commit is contained in:
parent
2bcdc5107b
commit
3397d1dc38
5 changed files with 71 additions and 1 deletions
|
@ -355,6 +355,34 @@ bool CArchive::copyProfileFiles()
|
|||
return copyFiles(files);
|
||||
}
|
||||
|
||||
bool CArchive::cleanServerFiles(const QString &directory)
|
||||
{
|
||||
QDir dir(directory);
|
||||
|
||||
// directory doesn't exist
|
||||
if (!dir.exists()) return false;
|
||||
|
||||
if (!dir.cd("data") && dir.exists()) return false;
|
||||
|
||||
// temporary files
|
||||
QStringList files = dir.entryList(QStringList() << "*.string_cache" << "*.packed_sheets" << "*.packed" << "*.pem", QDir::Files);
|
||||
|
||||
foreach(const QString &file, files)
|
||||
{
|
||||
dir.remove(file);
|
||||
}
|
||||
|
||||
// fonts directory is not needed anymore
|
||||
if (dir.cd("fonts") && dir.exists())
|
||||
{
|
||||
dir.removeRecursively();
|
||||
}
|
||||
|
||||
emit done();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CArchive::copyServerFiles(const QString &src, const QString &dst)
|
||||
{
|
||||
if (src.isEmpty() || dst.isEmpty()) return false;
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
bool extract(const QString &filename, const QString &dest);
|
||||
bool copyServerFiles(const QString &src, const QString &dst);
|
||||
bool copyProfileFiles(const QString &src, const QString &dst);
|
||||
bool cleanServerFiles(const QString &directory);
|
||||
|
||||
void stop();
|
||||
bool mustStop();
|
||||
|
|
|
@ -420,13 +420,41 @@ bool CConfigFile::isRyzomClientInstalledIn(const QString &directory) const
|
|||
// client_default.cfg doesn't exist
|
||||
if (!dir.exists("client_default.cfg")) return false;
|
||||
|
||||
if (!dir.exists(getServer().clientFilename)) return false;
|
||||
QString clientFilename = getServer().clientFilename;
|
||||
|
||||
// check if client is defined and exists
|
||||
if (!clientFilename.isEmpty() && !dir.exists(clientFilename)) return false;
|
||||
|
||||
// TODO: more checks
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CConfigFile::foundTemporaryFiles(const QString &directory) const
|
||||
{
|
||||
QDir dir(directory);
|
||||
|
||||
// directory doesn't exist
|
||||
if (!dir.exists()) return false;
|
||||
|
||||
if (!dir.cd("data") && dir.exists()) return false;
|
||||
|
||||
// temporary files
|
||||
if (!dir.entryList(QStringList() << "*.string_cache" << "*.packed_sheets" << "*.packed" << "*.pem", QDir::Files).isEmpty()) return true;
|
||||
|
||||
// fonts directory is not needed anymore
|
||||
if (dir.cd("fonts") && dir.exists()) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CConfigFile::shouldCreateDesktopShortcut() const
|
||||
{
|
||||
const CProfile &profile = getProfile();
|
||||
|
||||
return profile.desktopShortcut && !QFile::exists(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/Ryzom.lnk");
|
||||
}
|
||||
|
||||
QString CConfigFile::getClientFullPath() const
|
||||
{
|
||||
QString path = getProfile().executable;
|
||||
|
@ -527,6 +555,11 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const
|
|||
// client is not extracted from BNP
|
||||
if (!isRyzomClientInstalledIn(serverDirectory))
|
||||
{
|
||||
if (foundTemporaryFiles(serverDirectory))
|
||||
{
|
||||
return CleanFiles;
|
||||
}
|
||||
|
||||
if (QFile::exists(getSrcServerClientBNPFullPath()))
|
||||
{
|
||||
return ExtractBnpClient;
|
||||
|
|
|
@ -87,6 +87,7 @@ public:
|
|||
ExtractDownloadedClient,
|
||||
CopyServerFiles,
|
||||
CopyProfileFiles,
|
||||
CleanFiles,
|
||||
ExtractBnpClient,
|
||||
CreateProfile,
|
||||
CreateShortcuts,
|
||||
|
@ -144,6 +145,8 @@ public:
|
|||
bool isRyzomInstalledIn(const QString &directory) const;
|
||||
bool areRyzomDataInstalledIn(const QString &directory) const;
|
||||
bool isRyzomClientInstalledIn(const QString &directory) const;
|
||||
bool foundTemporaryFiles(const QString &directory) const;
|
||||
bool shouldCreateDesktopShortcut() const;
|
||||
|
||||
// installation choices
|
||||
bool use64BitsClient() const;
|
||||
|
|
|
@ -135,6 +135,11 @@ void CMainWindow::processNextStep()
|
|||
m_archive->extract(config->getSrcServerClientBNPFullPath(), config->getInstallationDirectory() + "/" + server.id);
|
||||
break;
|
||||
|
||||
case CConfigFile::CleanFiles:
|
||||
hideProgressBar();
|
||||
m_archive->cleanServerFiles(config->getInstallationDirectory() + "/" + server.id);
|
||||
break;
|
||||
|
||||
case CConfigFile::CreateProfile:
|
||||
displayProgressBar();
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue