NOISSUE Download all mods before writing the instance for modpacks.ch
This is prepatory work for implementing jarmods support for modpacks.ch, where we will need to look through files in a directory - which would require that those files are present at such time. This might even fix some weird bugs, maybe - I've not encountered any bugs from how this previously worked, but I feel that what's going on is slightly clearer now.
This commit is contained in:
parent
384680ca13
commit
9d91cd496f
@ -76,7 +76,7 @@ void PackInstallTask::onDownloadSucceeded()
|
|||||||
}
|
}
|
||||||
m_version = version;
|
m_version = version;
|
||||||
|
|
||||||
install();
|
downloadPack();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackInstallTask::onDownloadFailed(QString reason)
|
void PackInstallTask::onDownloadFailed(QString reason)
|
||||||
@ -85,6 +85,45 @@ void PackInstallTask::onDownloadFailed(QString reason)
|
|||||||
emitFailed(reason);
|
emitFailed(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PackInstallTask::downloadPack()
|
||||||
|
{
|
||||||
|
setStatus(tr("Downloading mods..."));
|
||||||
|
|
||||||
|
jobPtr.reset(new NetJob(tr("Mod download")));
|
||||||
|
for(auto file : m_version.files) {
|
||||||
|
if(file.serverOnly) continue;
|
||||||
|
|
||||||
|
auto relpath = FS::PathCombine("minecraft", file.path, file.name);
|
||||||
|
auto path = FS::PathCombine(m_stagingPath, relpath);
|
||||||
|
|
||||||
|
qDebug() << "Will download" << file.url << "to" << path;
|
||||||
|
auto dl = Net::Download::makeFile(file.url, path);
|
||||||
|
jobPtr->addNetAction(dl);
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(jobPtr.get(), &NetJob::succeeded, this, [&]()
|
||||||
|
{
|
||||||
|
jobPtr.reset();
|
||||||
|
install();
|
||||||
|
});
|
||||||
|
connect(jobPtr.get(), &NetJob::failed, [&](QString reason)
|
||||||
|
{
|
||||||
|
jobPtr.reset();
|
||||||
|
|
||||||
|
// FIXME: Temporarily ignore file download failures (matching FTB's installer),
|
||||||
|
// while FTB's data is fucked.
|
||||||
|
qWarning() << "Failed to download files for modpack: " + reason;
|
||||||
|
|
||||||
|
install();
|
||||||
|
});
|
||||||
|
connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total)
|
||||||
|
{
|
||||||
|
setProgress(current, total);
|
||||||
|
});
|
||||||
|
|
||||||
|
jobPtr->start();
|
||||||
|
}
|
||||||
|
|
||||||
void PackInstallTask::install()
|
void PackInstallTask::install()
|
||||||
{
|
{
|
||||||
setStatus(tr("Installing modpack"));
|
setStatus(tr("Installing modpack"));
|
||||||
@ -116,45 +155,14 @@ void PackInstallTask::install()
|
|||||||
components->setComponentVersion("net.fabricmc.fabric-loader", target.version, true);
|
components->setComponentVersion("net.fabricmc.fabric-loader", target.version, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
components->saveNow();
|
components->saveNow();
|
||||||
|
|
||||||
jobPtr.reset(new NetJob(tr("Mod download")));
|
|
||||||
for(auto file : m_version.files) {
|
|
||||||
if(file.serverOnly) continue;
|
|
||||||
|
|
||||||
auto relpath = FS::PathCombine("minecraft", file.path, file.name);
|
|
||||||
auto path = FS::PathCombine(m_stagingPath, relpath);
|
|
||||||
|
|
||||||
qDebug() << "Will download" << file.url << "to" << path;
|
|
||||||
auto dl = Net::Download::makeFile(file.url, path);
|
|
||||||
jobPtr->addNetAction(dl);
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(jobPtr.get(), &NetJob::succeeded, this, [&]()
|
|
||||||
{
|
|
||||||
jobPtr.reset();
|
|
||||||
emitSucceeded();
|
|
||||||
});
|
|
||||||
connect(jobPtr.get(), &NetJob::failed, [&](QString reason)
|
|
||||||
{
|
|
||||||
jobPtr.reset();
|
|
||||||
|
|
||||||
// FIXME: Temporarily ignore file download failures (matching FTB's installer),
|
|
||||||
// while FTB's data is fucked.
|
|
||||||
qWarning() << "Failed to download files for modpack: " + reason;
|
|
||||||
emitSucceeded();
|
|
||||||
});
|
|
||||||
connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total)
|
|
||||||
{
|
|
||||||
setProgress(current, total);
|
|
||||||
});
|
|
||||||
|
|
||||||
setStatus(tr("Downloading mods..."));
|
|
||||||
jobPtr->start();
|
|
||||||
|
|
||||||
instance.setName(m_instName);
|
instance.setName(m_instName);
|
||||||
instance.setIconKey(m_instIcon);
|
instance.setIconKey(m_instIcon);
|
||||||
instanceSettings->resumeSave();
|
instanceSettings->resumeSave();
|
||||||
|
|
||||||
|
emitSucceeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ private slots:
|
|||||||
void onDownloadFailed(QString reason);
|
void onDownloadFailed(QString reason);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void downloadPack();
|
||||||
void install();
|
void install();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user