mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
Don't use .index for shaderpacks
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
d6942089cd
commit
1cf48dfd85
5 changed files with 82 additions and 2 deletions
56
launcher/minecraft/mod/ShaderPackFolderModel.cpp
Normal file
56
launcher/minecraft/mod/ShaderPackFolderModel.cpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#include "ShaderPackFolderModel.h"
|
||||
|
||||
namespace {
|
||||
class ShaderPackIndexMigrateTask : public Task {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ShaderPackIndexMigrateTask(QDir resourceDir, QDir indexDir) : m_resourceDir(std::move(resourceDir)), m_indexDir(std::move(indexDir)) {}
|
||||
|
||||
void executeTask() override
|
||||
{
|
||||
if (!m_indexDir.exists()) {
|
||||
qDebug() << m_indexDir.absolutePath() << "does not exist; nothing to migrate";
|
||||
emitSucceeded();
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList pwFiles = m_indexDir.entryList({ "*.pw.toml" }, QDir::Files);
|
||||
bool movedAll = true;
|
||||
|
||||
for (const auto& file : pwFiles) {
|
||||
QString src = m_indexDir.filePath(file);
|
||||
QString dest = m_resourceDir.filePath(file);
|
||||
|
||||
if (QFile::rename(src, dest)) {
|
||||
qDebug() << "Moved" << src << "to" << dest;
|
||||
} else {
|
||||
movedAll = false;
|
||||
qDebug() << "Error moving" << src << "to" << dest;
|
||||
}
|
||||
}
|
||||
|
||||
if (!movedAll) {
|
||||
// FIXME: not shown in the UI
|
||||
emitFailed(tr("Failed to migrate everything from .index"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_indexDir.removeRecursively()) {
|
||||
emitFailed(tr("Failed to remove old .index dir"));
|
||||
return;
|
||||
}
|
||||
|
||||
emitSucceeded();
|
||||
}
|
||||
|
||||
private:
|
||||
QDir m_resourceDir, m_indexDir;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
Task* ShaderPackFolderModel::createPreUpdateTask()
|
||||
{
|
||||
return new ShaderPackIndexMigrateTask(m_dir, ResourceFolderModel::indexDir());
|
||||
}
|
||||
|
||||
#include "ShaderPackFolderModel.moc"
|
||||
Loading…
Add table
Add a link
Reference in a new issue