Changed: Clean files

--HG--
branch : feature-ryzom-installer
This commit is contained in:
kervala 2016-05-14 18:50:27 +02:00
parent 2bcdc5107b
commit 3397d1dc38
5 changed files with 71 additions and 1 deletions

View file

@ -355,6 +355,34 @@ bool CArchive::copyProfileFiles()
return copyFiles(files); 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) bool CArchive::copyServerFiles(const QString &src, const QString &dst)
{ {
if (src.isEmpty() || dst.isEmpty()) return false; if (src.isEmpty() || dst.isEmpty()) return false;

View file

@ -34,6 +34,7 @@ public:
bool extract(const QString &filename, const QString &dest); bool extract(const QString &filename, const QString &dest);
bool copyServerFiles(const QString &src, const QString &dst); bool copyServerFiles(const QString &src, const QString &dst);
bool copyProfileFiles(const QString &src, const QString &dst); bool copyProfileFiles(const QString &src, const QString &dst);
bool cleanServerFiles(const QString &directory);
void stop(); void stop();
bool mustStop(); bool mustStop();

View file

@ -420,13 +420,41 @@ bool CConfigFile::isRyzomClientInstalledIn(const QString &directory) const
// client_default.cfg doesn't exist // client_default.cfg doesn't exist
if (!dir.exists("client_default.cfg")) return false; 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 // TODO: more checks
return true; 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 CConfigFile::getClientFullPath() const
{ {
QString path = getProfile().executable; QString path = getProfile().executable;
@ -527,6 +555,11 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const
// client is not extracted from BNP // client is not extracted from BNP
if (!isRyzomClientInstalledIn(serverDirectory)) if (!isRyzomClientInstalledIn(serverDirectory))
{ {
if (foundTemporaryFiles(serverDirectory))
{
return CleanFiles;
}
if (QFile::exists(getSrcServerClientBNPFullPath())) if (QFile::exists(getSrcServerClientBNPFullPath()))
{ {
return ExtractBnpClient; return ExtractBnpClient;

View file

@ -87,6 +87,7 @@ public:
ExtractDownloadedClient, ExtractDownloadedClient,
CopyServerFiles, CopyServerFiles,
CopyProfileFiles, CopyProfileFiles,
CleanFiles,
ExtractBnpClient, ExtractBnpClient,
CreateProfile, CreateProfile,
CreateShortcuts, CreateShortcuts,
@ -144,6 +145,8 @@ public:
bool isRyzomInstalledIn(const QString &directory) const; bool isRyzomInstalledIn(const QString &directory) const;
bool areRyzomDataInstalledIn(const QString &directory) const; bool areRyzomDataInstalledIn(const QString &directory) const;
bool isRyzomClientInstalledIn(const QString &directory) const; bool isRyzomClientInstalledIn(const QString &directory) const;
bool foundTemporaryFiles(const QString &directory) const;
bool shouldCreateDesktopShortcut() const;
// installation choices // installation choices
bool use64BitsClient() const; bool use64BitsClient() const;

View file

@ -135,6 +135,11 @@ void CMainWindow::processNextStep()
m_archive->extract(config->getSrcServerClientBNPFullPath(), config->getInstallationDirectory() + "/" + server.id); m_archive->extract(config->getSrcServerClientBNPFullPath(), config->getInstallationDirectory() + "/" + server.id);
break; break;
case CConfigFile::CleanFiles:
hideProgressBar();
m_archive->cleanServerFiles(config->getInstallationDirectory() + "/" + server.id);
break;
case CConfigFile::CreateProfile: case CConfigFile::CreateProfile:
displayProgressBar(); displayProgressBar();
break; break;