fix: explicit QFileInfo converison for qt6

fix: validatePath in validateZIPResouces

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers 2022-12-25 17:16:26 -07:00
parent 78984eea3a
commit b2082bfde7

View File

@ -564,15 +564,13 @@ void FlameCreationTask::validateZIPResouces()
auto localPath = FS::PathCombine(m_stagingPath, "minecraft", targetFolder, fileName); auto localPath = FS::PathCombine(m_stagingPath, "minecraft", targetFolder, fileName);
auto validatePath = [&localPath, this](QString fileName, QString targetFolder, QString realTarget) { auto validatePath = [&localPath, this](QString fileName, QString targetFolder, QString realTarget) {
if (targetFolder != "resourcepacks") { if (targetFolder != realTarget) {
qDebug() << "Target folder of" << fileName << "is incorrect, it's a resource pack."; qDebug() << "Target folder of" << fileName << "is incorrect, it belongs in" << realTarget;
auto destPath = FS::PathCombine(m_stagingPath, "minecraft", "resourcepacks", fileName); auto destPath = FS::PathCombine(m_stagingPath, "minecraft", realTarget, fileName);
qDebug() << "Moving" << localPath << "to" << destPath; qDebug() << "Moving" << localPath << "to" << destPath;
if (moveFile(localPath, destPath)) { if (moveFile(localPath, destPath)) {
return destPath; return destPath;
} }
} else {
qDebug() << fileName << "is in the right place :" << targetFolder;
} }
return localPath; return localPath;
}; };
@ -580,18 +578,24 @@ void FlameCreationTask::validateZIPResouces()
QFileInfo localFileInfo(localPath); QFileInfo localFileInfo(localPath);
if (localFileInfo.exists() && localFileInfo.isFile()) { if (localFileInfo.exists() && localFileInfo.isFile()) {
if (ResourcePackUtils::validate(localFileInfo)) { if (ResourcePackUtils::validate(localFileInfo)) {
qDebug() << fileName << "is a resource pack";
validatePath(fileName, targetFolder, "resourcepacks"); validatePath(fileName, targetFolder, "resourcepacks");
} else if (TexturePackUtils::validate(localFileInfo)) { } else if (TexturePackUtils::validate(localFileInfo)) {
qDebug() << fileName << "is a pre 1.6 texture pack";
validatePath(fileName, targetFolder, "texturepacks"); validatePath(fileName, targetFolder, "texturepacks");
} else if (DataPackUtils::validate(localFileInfo)) { } else if (DataPackUtils::validate(localFileInfo)) {
qDebug() << fileName << "is a data pack";
validatePath(fileName, targetFolder, "datapacks"); validatePath(fileName, targetFolder, "datapacks");
} else if (ModUtils::validate(localFileInfo)) { } else if (ModUtils::validate(localFileInfo)) {
qDebug() << fileName << "is a mod";
validatePath(fileName, targetFolder, "mods"); validatePath(fileName, targetFolder, "mods");
} else if (WorldSaveUtils::validate(localFileInfo)) { } else if (WorldSaveUtils::validate(localFileInfo)) {
qDebug() << fileName << "is a world save";
QString worldPath = validatePath(fileName, targetFolder, "saves"); QString worldPath = validatePath(fileName, targetFolder, "saves");
qDebug() << "Installing World from" << worldPath; qDebug() << "Installing World from" << worldPath;
World w(worldPath); QFileInfo worldFileInfo(worldPath);
World w(worldFileInfo);
if (!w.isValid()) { if (!w.isValid()) {
qDebug() << "World at" << worldPath << "is not valid, skipping install."; qDebug() << "World at" << worldPath << "is not valid, skipping install.";
} else { } else {
@ -600,6 +604,7 @@ void FlameCreationTask::validateZIPResouces()
} else if (ShaderPackUtils::validate(localFileInfo)) { } else if (ShaderPackUtils::validate(localFileInfo)) {
// in theroy flame API can't do this but who knows, that *may* change ? // in theroy flame API can't do this but who knows, that *may* change ?
// better to handle it if it *does* occure in the future // better to handle it if it *does* occure in the future
qDebug() << fileName << "is a shader pack";
validatePath(fileName, targetFolder, "shaderpacks"); validatePath(fileName, targetFolder, "shaderpacks");
} else { } else {
qDebug() << "Can't Identify" << fileName << "at" << localPath << ", leaving it where it is."; qDebug() << "Can't Identify" << fileName << "at" << localPath << ", leaving it where it is.";