From fc28aacdea3e7331b0f5f4436e0dac2fd361c390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 15 Apr 2017 11:40:22 +0200 Subject: [PATCH] NOISSUE stop using the `path` attributes from Mojang download info It really should not dictate how are things stored and it just makes the metadata bigger for no reason. --- api/logic/meta/BaseEntity.cpp | 2 +- api/logic/minecraft/Library.cpp | 85 ++++++++++----------------------- 2 files changed, 26 insertions(+), 61 deletions(-) diff --git a/api/logic/meta/BaseEntity.cpp b/api/logic/meta/BaseEntity.cpp index 633afab2..e0f43bc2 100644 --- a/api/logic/meta/BaseEntity.cpp +++ b/api/logic/meta/BaseEntity.cpp @@ -74,7 +74,7 @@ Meta::BaseEntity::~BaseEntity() QUrl Meta::BaseEntity::url() const { - return QUrl("https://meta.multimc.org").resolved(localFilename()); + return QUrl("https://meta-dev.multimc.org").resolved(localFilename()); } bool Meta::BaseEntity::loadLocalFile() diff --git a/api/logic/minecraft/Library.cpp b/api/logic/minecraft/Library.cpp index 7521a049..a3b5f01c 100644 --- a/api/logic/minecraft/Library.cpp +++ b/api/logic/minecraft/Library.cpp @@ -28,69 +28,26 @@ void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& na } return out.absoluteFilePath(); }; - if(m_mojangDownloads) + QString raw_storage = storageSuffix(system); + if(isNative()) { - if(!isNative()) + if (raw_storage.contains("${arch}")) { - if(m_mojangDownloads->artifact) - { - auto artifact = m_mojangDownloads->artifact; - jar += actualPath(artifact->path); - } + auto nat32Storage = raw_storage; + nat32Storage.replace("${arch}", "32"); + auto nat64Storage = raw_storage; + nat64Storage.replace("${arch}", "64"); + native32 += actualPath(nat32Storage); + native64 += actualPath(nat64Storage); } - else if(m_nativeClassifiers.contains(system)) + else { - auto nativeClassifier = m_nativeClassifiers[system]; - if(nativeClassifier.contains("${arch}")) - { - auto nat32Classifier = nativeClassifier; - nat32Classifier.replace("${arch}", "32"); - auto nat64Classifier = nativeClassifier; - nat64Classifier.replace("${arch}", "64"); - auto nat32info = m_mojangDownloads->getDownloadInfo(nat32Classifier); - if(nat32info) - native32 += actualPath(nat32info->path); - auto nat64info = m_mojangDownloads->getDownloadInfo(nat64Classifier); - if(nat64info) - native64 += actualPath(nat64info->path); - } - else - { - auto dlinfo = m_mojangDownloads->getDownloadInfo(nativeClassifier); - if(!dlinfo) - { - qWarning() << "Cannot get native for" << nativeClassifier << "while processing" << m_name; - } - else - { - native += actualPath(dlinfo->path); - } - } + native += actualPath(raw_storage); } } else { - QString raw_storage = storageSuffix(system); - if(isNative()) - { - if (raw_storage.contains("${arch}")) - { - auto nat32Storage = raw_storage; - nat32Storage.replace("${arch}", "32"); - auto nat64Storage = raw_storage; - nat64Storage.replace("${arch}", "64"); - native32 += actualPath(nat32Storage); - native64 += actualPath(nat64Storage); - } - else - { - native += actualPath(raw_storage); - } - } - else - { - jar += actualPath(raw_storage); - } + jar += actualPath(raw_storage); } } @@ -165,12 +122,13 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads(OpSys system, class return true; }; + QString raw_storage = storageSuffix(system); if(m_mojangDownloads) { if(m_mojangDownloads->artifact) { auto artifact = m_mojangDownloads->artifact; - add_download(artifact->path, artifact->url, artifact->sha1); + add_download(raw_storage, artifact->url, artifact->sha1); } if(m_nativeClassifiers.contains(system)) { @@ -183,24 +141,31 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads(OpSys system, class nat64Classifier.replace("${arch}", "64"); auto nat32info = m_mojangDownloads->getDownloadInfo(nat32Classifier); if(nat32info) - add_download(nat32info->path, nat32info->url, nat32info->sha1); + { + auto cooked_storage = raw_storage; + cooked_storage.replace("${arch}", "32"); + add_download(cooked_storage, nat32info->url, nat32info->sha1); + } auto nat64info = m_mojangDownloads->getDownloadInfo(nat64Classifier); if(nat64info) - add_download(nat64info->path, nat64info->url, nat64info->sha1); + { + auto cooked_storage = raw_storage; + cooked_storage.replace("${arch}", "64"); + add_download(cooked_storage, nat64info->url, nat64info->sha1); + } } else { auto info = m_mojangDownloads->getDownloadInfo(nativeClassifier); if(info) { - add_download(info->path, info->url, info->sha1); + add_download(raw_storage, info->url, info->sha1); } } } } else { - QString raw_storage = storageSuffix(system); auto raw_dl = [&](){ if (!m_absoluteURL.isEmpty()) {