Reduced temporary instance folder name

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2024-02-22 19:40:24 +02:00
parent 1cdb9bd5af
commit 726b0ffb3b
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318

View File

@ -38,6 +38,7 @@
#include <QDir> #include <QDir>
#include <QDirIterator> #include <QDirIterator>
#include <QFile> #include <QFile>
#include <QFileInfo>
#include <QFileSystemWatcher> #include <QFileSystemWatcher>
#include <QJsonArray> #include <QJsonArray>
#include <QJsonDocument> #include <QJsonDocument>
@ -933,8 +934,12 @@ Task* InstanceList::wrapInstanceTask(InstanceTask* task)
QString InstanceList::getStagedInstancePath() QString InstanceList::getStagedInstancePath()
{ {
QString key = QUuid::createUuid().toString(QUuid::WithoutBraces);
QString tempDir = ".LAUNCHER_TEMP/"; QString tempDir = ".LAUNCHER_TEMP/";
auto tempPath = FS::PathCombine(m_instDir, tempDir);
if (QFileInfo::exists(tempPath)) {
FS::deletePath(tempPath); // clean the path to prevent any collisions
}
QString key = QUuid::createUuid().toString(QUuid::WithoutBraces).left(6); // reduce the size from 36 to 6
QString relPath = FS::PathCombine(tempDir, key); QString relPath = FS::PathCombine(tempDir, key);
QDir rootPath(m_instDir); QDir rootPath(m_instDir);
auto path = FS::PathCombine(m_instDir, relPath); auto path = FS::PathCombine(m_instDir, relPath);
@ -942,7 +947,6 @@ QString InstanceList::getStagedInstancePath()
return QString(); return QString();
} }
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
auto tempPath = FS::PathCombine(m_instDir, tempDir);
SetFileAttributesA(tempPath.toStdString().c_str(), FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED); SetFileAttributesA(tempPath.toStdString().c_str(), FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED);
#endif #endif
return path; return path;