fix: correct ftb legacy too
Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
dfa220ef02
commit
c90a88b6b6
@ -65,48 +65,42 @@ void PackInstallTask::executeTask()
|
|||||||
void PackInstallTask::downloadPack()
|
void PackInstallTask::downloadPack()
|
||||||
{
|
{
|
||||||
setStatus(tr("Downloading zip for %1").arg(m_pack.name));
|
setStatus(tr("Downloading zip for %1").arg(m_pack.name));
|
||||||
|
setAbortable(false);
|
||||||
|
|
||||||
|
archivePath = QString("%1/%2/%3").arg(m_pack.dir, m_version.replace(".", "_"), m_pack.file);
|
||||||
|
|
||||||
auto packoffset = QString("%1/%2/%3").arg(m_pack.dir, m_version.replace(".", "_"), m_pack.file);
|
|
||||||
auto entry = APPLICATION->metacache()->resolveEntry("FTBPacks", packoffset);
|
|
||||||
netJobContainer = new NetJob("Download FTB Pack", m_network);
|
netJobContainer = new NetJob("Download FTB Pack", m_network);
|
||||||
|
|
||||||
entry->setStale(true);
|
|
||||||
QString url;
|
QString url;
|
||||||
if(m_pack.type == PackType::Private)
|
if (m_pack.type == PackType::Private) {
|
||||||
{
|
url = QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "privatepacks/%1").arg(archivePath);
|
||||||
url = QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "privatepacks/%1").arg(packoffset);
|
} else {
|
||||||
|
url = QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "modpacks/%1").arg(archivePath);
|
||||||
}
|
}
|
||||||
else
|
netJobContainer->addNetAction(Net::Download::makeFile(url, archivePath));
|
||||||
{
|
|
||||||
url = QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "modpacks/%1").arg(packoffset);
|
|
||||||
}
|
|
||||||
netJobContainer->addNetAction(Net::Download::makeCached(url, entry));
|
|
||||||
archivePath = entry->getFullPath();
|
|
||||||
|
|
||||||
connect(netJobContainer.get(), &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
|
connect(netJobContainer.get(), &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
|
||||||
connect(netJobContainer.get(), &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
|
connect(netJobContainer.get(), &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
|
||||||
connect(netJobContainer.get(), &NetJob::progress, this, &PackInstallTask::onDownloadProgress);
|
connect(netJobContainer.get(), &NetJob::progress, this, &PackInstallTask::onDownloadProgress);
|
||||||
connect(netJobContainer.get(), &NetJob::aborted, this, &PackInstallTask::onDownloadAborted);
|
connect(netJobContainer.get(), &NetJob::aborted, this, &PackInstallTask::onDownloadAborted);
|
||||||
|
|
||||||
netJobContainer->start();
|
netJobContainer->start();
|
||||||
|
|
||||||
|
setAbortable(true);
|
||||||
progress(1, 4);
|
progress(1, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackInstallTask::onDownloadSucceeded()
|
void PackInstallTask::onDownloadSucceeded()
|
||||||
{
|
{
|
||||||
abortable = false;
|
|
||||||
unzip();
|
unzip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackInstallTask::onDownloadFailed(QString reason)
|
void PackInstallTask::onDownloadFailed(QString reason)
|
||||||
{
|
{
|
||||||
abortable = false;
|
|
||||||
emitFailed(reason);
|
emitFailed(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackInstallTask::onDownloadProgress(qint64 current, qint64 total)
|
void PackInstallTask::onDownloadProgress(qint64 current, qint64 total)
|
||||||
{
|
{
|
||||||
abortable = true;
|
|
||||||
progress(current, total * 4);
|
progress(current, total * 4);
|
||||||
setStatus(tr("Downloading zip for %1 (%2%)").arg(m_pack.name).arg(current / 10));
|
setStatus(tr("Downloading zip for %1 (%2%)").arg(m_pack.name).arg(current / 10));
|
||||||
}
|
}
|
||||||
@ -118,8 +112,10 @@ void PackInstallTask::onDownloadAborted()
|
|||||||
|
|
||||||
void PackInstallTask::unzip()
|
void PackInstallTask::unzip()
|
||||||
{
|
{
|
||||||
progress(2, 4);
|
|
||||||
setStatus(tr("Extracting modpack"));
|
setStatus(tr("Extracting modpack"));
|
||||||
|
setAbortable(false);
|
||||||
|
progress(2, 4);
|
||||||
|
|
||||||
QDir extractDir(m_stagingPath);
|
QDir extractDir(m_stagingPath);
|
||||||
|
|
||||||
m_packZip.reset(new QuaZip(archivePath));
|
m_packZip.reset(new QuaZip(archivePath));
|
||||||
@ -151,8 +147,8 @@ void PackInstallTask::onUnzipCanceled()
|
|||||||
|
|
||||||
void PackInstallTask::install()
|
void PackInstallTask::install()
|
||||||
{
|
{
|
||||||
progress(3, 4);
|
|
||||||
setStatus(tr("Installing modpack"));
|
setStatus(tr("Installing modpack"));
|
||||||
|
progress(3, 4);
|
||||||
QDir unzipMcDir(m_stagingPath + "/unzip/minecraft");
|
QDir unzipMcDir(m_stagingPath + "/unzip/minecraft");
|
||||||
if(unzipMcDir.exists())
|
if(unzipMcDir.exists())
|
||||||
{
|
{
|
||||||
@ -247,11 +243,12 @@ void PackInstallTask::install()
|
|||||||
|
|
||||||
bool PackInstallTask::abort()
|
bool PackInstallTask::abort()
|
||||||
{
|
{
|
||||||
if(abortable)
|
if (!canAbort()) {
|
||||||
{
|
return false;
|
||||||
return netJobContainer->abort();
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
netJobContainer->abort();
|
||||||
|
return InstanceTask::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user