fix(Inst.Import): don't search inside 'overrides/' for the manifest
It will never be there anyways, and saves a **bunch** of time when the overrides folder is big and we traverse all the tree when searching for the MMC 'instance.cfg' file. Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
9e1653ebb4
commit
a116778402
@ -164,18 +164,14 @@ void InstanceImportTask::processZipPack()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString mmcRoot = MMCZip::findFolderOfFileInZip(m_packZip.get(), "instance.cfg");
|
QStringList paths_to_ignore { "overrides/" };
|
||||||
QString flameRoot = MMCZip::findFolderOfFileInZip(m_packZip.get(), "manifest.json");
|
|
||||||
|
|
||||||
if (!mmcRoot.isNull())
|
if (QString mmcRoot = MMCZip::findFolderOfFileInZip(m_packZip.get(), "instance.cfg", paths_to_ignore); !mmcRoot.isNull()) {
|
||||||
{
|
|
||||||
// process as MultiMC instance/pack
|
// process as MultiMC instance/pack
|
||||||
qDebug() << "MultiMC:" << mmcRoot;
|
qDebug() << "MultiMC:" << mmcRoot;
|
||||||
root = mmcRoot;
|
root = mmcRoot;
|
||||||
m_modpackType = ModpackType::MultiMC;
|
m_modpackType = ModpackType::MultiMC;
|
||||||
}
|
} else if (QString flameRoot = MMCZip::findFolderOfFileInZip(m_packZip.get(), "manifest.json", paths_to_ignore); !flameRoot.isNull()) {
|
||||||
else if(!flameRoot.isNull())
|
|
||||||
{
|
|
||||||
// process as Flame pack
|
// process as Flame pack
|
||||||
qDebug() << "Flame:" << flameRoot;
|
qDebug() << "Flame:" << flameRoot;
|
||||||
root = flameRoot;
|
root = flameRoot;
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "MMCZip.h"
|
#include "MMCZip.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
// ours
|
// ours
|
||||||
@ -228,23 +229,27 @@ bool MMCZip::createModdedJar(QString sourceJarPath, QString targetJarPath, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ours
|
// ours
|
||||||
QString MMCZip::findFolderOfFileInZip(QuaZip * zip, const QString & what, const QString &root)
|
QString MMCZip::findFolderOfFileInZip(QuaZip* zip, const QString& what, const QStringList& ignore_paths, const QString& root)
|
||||||
{
|
{
|
||||||
QuaZipDir rootDir(zip, root);
|
QuaZipDir rootDir(zip, root);
|
||||||
for(auto fileName: rootDir.entryList(QDir::Files))
|
for (auto&& fileName : rootDir.entryList(QDir::Files)) {
|
||||||
{
|
if (fileName == what)
|
||||||
if(fileName == what)
|
|
||||||
return root;
|
return root;
|
||||||
|
|
||||||
|
QCoreApplication::processEvents();
|
||||||
}
|
}
|
||||||
for(auto fileName: rootDir.entryList(QDir::Dirs))
|
|
||||||
{
|
// Recurse the search to non-ignored subfolders
|
||||||
QString result = findFolderOfFileInZip(zip, what, root + fileName);
|
for (auto&& fileName : rootDir.entryList(QDir::Dirs)) {
|
||||||
if(!result.isEmpty())
|
if (ignore_paths.contains(fileName))
|
||||||
{
|
continue;
|
||||||
|
|
||||||
|
QString result = findFolderOfFileInZip(zip, what, ignore_paths, root + fileName);
|
||||||
|
if (!result.isEmpty())
|
||||||
return result;
|
return result;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return QString();
|
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// ours
|
// ours
|
||||||
|
@ -80,9 +80,11 @@ namespace MMCZip
|
|||||||
/**
|
/**
|
||||||
* Find a single file in archive by file name (not path)
|
* Find a single file in archive by file name (not path)
|
||||||
*
|
*
|
||||||
|
* \param ignore_paths paths to skip when recursing the search
|
||||||
|
*
|
||||||
* \return the path prefix where the file is
|
* \return the path prefix where the file is
|
||||||
*/
|
*/
|
||||||
QString findFolderOfFileInZip(QuaZip * zip, const QString & what, const QString &root = QString(""));
|
QString findFolderOfFileInZip(QuaZip * zip, const QString & what, const QStringList& ignore_paths = {}, const QString &root = QString(""));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a multiple files of the same name in archive by file name
|
* Find a multiple files of the same name in archive by file name
|
||||||
|
Loading…
Reference in New Issue
Block a user