GH-2026 fix native library downloads

If a single library had both native and java jars, they would randomly get confused.
This commit is contained in:
Petr Mrázek 2017-10-28 21:12:12 +02:00
parent ab870648bd
commit 3eebc641f9

View File

@ -104,6 +104,7 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads(OpSys system, class
} }
if (isForge) if (isForge)
{ {
qDebug() << "XzDownload for:" << rawName() << "storage:" << storage << "url:" << url;
out.append(ForgeXzDownload::make(storage, entry)); out.append(ForgeXzDownload::make(storage, entry));
} }
else else
@ -113,11 +114,14 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads(OpSys system, class
auto rawSha1 = QByteArray::fromHex(sha1.toLatin1()); auto rawSha1 = QByteArray::fromHex(sha1.toLatin1());
auto dl = Net::Download::makeCached(url, entry, options); auto dl = Net::Download::makeCached(url, entry, options);
dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1)); dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1));
qDebug() << "Checksummed Download for:" << rawName() << "storage:" << storage << "url:" << url;
out.append(dl); out.append(dl);
} }
else else
{
out.append(Net::Download::makeCached(url, entry, options)); out.append(Net::Download::makeCached(url, entry, options));
qDebug() << "Download for:" << rawName() << "storage:" << storage << "url:" << url;
}
} }
return true; return true;
}; };
@ -125,11 +129,8 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads(OpSys system, class
QString raw_storage = storageSuffix(system); QString raw_storage = storageSuffix(system);
if(m_mojangDownloads) if(m_mojangDownloads)
{ {
if(m_mojangDownloads->artifact) if(isNative())
{ {
auto artifact = m_mojangDownloads->artifact;
add_download(raw_storage, artifact->url, artifact->sha1);
}
if(m_nativeClassifiers.contains(system)) if(m_nativeClassifiers.contains(system))
{ {
auto nativeClassifier = m_nativeClassifiers[system]; auto nativeClassifier = m_nativeClassifiers[system];
@ -163,6 +164,23 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads(OpSys system, class
} }
} }
} }
else
{
qDebug() << "Ignoring native library" << m_name << "because it has no classifier for current OS";
}
}
else
{
if(m_mojangDownloads->artifact)
{
auto artifact = m_mojangDownloads->artifact;
add_download(raw_storage, artifact->url, artifact->sha1);
}
else
{
qDebug() << "Ignoring java library" << m_name << "because it has no artifact";
}
}
} }
else else
{ {