| 84 | } |
| 85 | |
| 86 | void InstanceImportTask::processZipPack() |
| 87 | { |
| 88 | setStatus(tr("Extracting modpack")); |
| 89 | QDir extractDir(m_stagingPath); |
| 90 | qDebug() << "Attempting to create instance from" << m_archivePath; |
| 91 | |
| 92 | // open the zip and find relevant files in it |
| 93 | m_packZip.reset(new QuaZip(m_archivePath)); |
| 94 | if (!m_packZip->open(QuaZip::mdUnzip)) |
| 95 | { |
| 96 | emitFailed(tr("Unable to open supplied modpack zip file.")); |
| 97 | return; |
| 98 | } |
| 99 | |
| 100 | QStringList blacklist = {"instance.cfg", "manifest.json"}; |
| 101 | QString mmcFound = MMCZip::findFolderOfFileInZip(m_packZip.get(), "instance.cfg"); |
| 102 | bool technicFound = QuaZipDir(m_packZip.get()).exists("/bin/modpack.jar") || QuaZipDir(m_packZip.get()).exists("/bin/version.json"); |
| 103 | QString flameFound = MMCZip::findFolderOfFileInZip(m_packZip.get(), "manifest.json"); |
| 104 | QString root; |
| 105 | if(!mmcFound.isNull()) |
| 106 | { |
| 107 | // process as MultiMC instance/pack |
| 108 | qDebug() << "MultiMC:" << mmcFound; |
| 109 | root = mmcFound; |
| 110 | m_modpackType = ModpackType::MultiMC; |
| 111 | } |
| 112 | else if (technicFound) |
| 113 | { |
| 114 | // process as Technic pack |
| 115 | qDebug() << "Technic:" << technicFound; |
| 116 | extractDir.mkpath(".minecraft"); |
| 117 | extractDir.cd(".minecraft"); |
| 118 | m_modpackType = ModpackType::Technic; |
| 119 | } |
| 120 | else if(!flameFound.isNull()) |
| 121 | { |
| 122 | // process as Flame pack |
| 123 | qDebug() << "Flame:" << flameFound; |
| 124 | root = flameFound; |
| 125 | m_modpackType = ModpackType::Flame; |
| 126 | } |
| 127 | if(m_modpackType == ModpackType::Unknown) |
| 128 | { |
| 129 | emitFailed(tr("Archive does not contain a recognized modpack type.")); |
| 130 | return; |
| 131 | } |
| 132 | |
| 133 | // make sure we extract just the pack |
| 134 | m_extractFuture = QtConcurrent::run(QThreadPool::globalInstance(), MMCZip::extractSubDir, m_packZip.get(), root, extractDir.absolutePath()); |
| 135 | connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::finished, this, &InstanceImportTask::extractFinished); |
| 136 | connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::canceled, this, &InstanceImportTask::extractAborted); |
| 137 | m_extractFutureWatcher.setFuture(m_extractFuture); |
| 138 | } |
| 139 | |
| 140 | void InstanceImportTask::extractFinished() |
| 141 | { |