diff options
Diffstat (limited to 'logic/OneSixUpdate.cpp')
-rw-r--r-- | logic/OneSixUpdate.cpp | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/logic/OneSixUpdate.cpp b/logic/OneSixUpdate.cpp index 2d8a167c..c69ff155 100644 --- a/logic/OneSixUpdate.cpp +++ b/logic/OneSixUpdate.cpp @@ -28,10 +28,11 @@ #include "OneSixVersion.h" #include "OneSixLibrary.h" #include "OneSixInstance.h" +#include "net/ForgeMirrors.h" #include "pathutils.h" -OneSixUpdate::OneSixUpdate(BaseInstance *inst, QObject *parent) : BaseUpdate(inst, parent) +OneSixUpdate::OneSixUpdate(BaseInstance *inst, QObject *parent) : Task(parent), m_inst(inst) { } @@ -142,7 +143,7 @@ void OneSixUpdate::jarlibStart() bool successful = inst->reloadFullVersion(); if (!successful) { - emitFailed("Failed to load the version description file (version.json). It might be " + emitFailed("Failed to load the version description file. It might be " "corrupted, missing or simply too new."); return; } @@ -163,20 +164,53 @@ void OneSixUpdate::jarlibStart() libs.append(version->getActiveNormalLibs()); auto metacache = MMC->metacache(); + QList<ForgeXzDownloadPtr> ForgeLibs; + bool already_forge_xz = false; for (auto lib : libs) { if (lib->hint() == "local") continue; - QString download_path = lib->downloadUrl(); - auto entry = metacache->resolveEntry("libraries", lib->storagePath()); + QString storage = lib->storagePath(); + QString dl = lib->downloadUrl(); + if (lib->isNative() && storage.contains("${arch}")) + { + auto storage64 = storage, storage32 = storage; + auto dl64 = dl, dl32 = dl; + storage64.replace("${arch}", "64"); + storage32.replace("${arch}", "32"); + dl32.replace("${arch}", "32"); + dl64.replace("${arch}", "64"); + + auto entry64 = metacache->resolveEntry("libraries", storage64); + if (entry64->stale) + jarlibDownloadJob->addNetAction(CacheDownload::make(dl64, entry64)); + + auto entry32 = metacache->resolveEntry("libraries", storage32); + if (entry32->stale) + jarlibDownloadJob->addNetAction(CacheDownload::make(dl32, entry32)); + continue; + } + auto entry = metacache->resolveEntry("libraries", storage); if (entry->stale) { if (lib->hint() == "forge-pack-xz") - jarlibDownloadJob->addNetAction(ForgeXzDownload::make(download_path, entry)); + { + ForgeLibs.append(ForgeXzDownload::make(storage, entry)); + } else - jarlibDownloadJob->addNetAction(CacheDownload::make(download_path, entry)); + { + jarlibDownloadJob->addNetAction(CacheDownload::make(dl, entry)); + } } } + // TODO: think about how to propagate this from the original json file... or IF AT ALL + QString forgeMirrorList = "http://files.minecraftforge.net/mirror-brand.list"; + if (!ForgeLibs.empty()) + { + jarlibDownloadJob->addNetAction( + ForgeMirrors::make(ForgeLibs, jarlibDownloadJob, forgeMirrorList)); + } + connect(jarlibDownloadJob.get(), SIGNAL(succeeded()), SLOT(jarlibFinished())); connect(jarlibDownloadJob.get(), SIGNAL(failed()), SLOT(jarlibFailed())); connect(jarlibDownloadJob.get(), SIGNAL(progress(qint64, qint64)), |