Finish assets update for 1.7.3
This commit is contained in:
@ -29,6 +29,7 @@
|
||||
#include "OneSixLibrary.h"
|
||||
#include "OneSixInstance.h"
|
||||
#include "net/ForgeMirrors.h"
|
||||
#include "assets/AssetsUtils.h"
|
||||
|
||||
#include "pathutils.h"
|
||||
#include <JlCompress.h>
|
||||
@ -50,7 +51,7 @@ void OneSixUpdate::executeTask()
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_only_prepare)
|
||||
if (m_only_prepare)
|
||||
{
|
||||
if (m_inst->shouldUpdate())
|
||||
{
|
||||
@ -93,7 +94,7 @@ void OneSixUpdate::checkJavaOnline()
|
||||
|
||||
checker.reset(new JavaChecker());
|
||||
connect(checker.get(), SIGNAL(checkFinished(JavaCheckResult)), this,
|
||||
SLOT(checkFinishedOnline(JavaCheckResult)));
|
||||
SLOT(checkFinishedOnline(JavaCheckResult)));
|
||||
checker->performCheck(java_path);
|
||||
}
|
||||
|
||||
@ -193,6 +194,96 @@ void OneSixUpdate::versionFileFailed()
|
||||
emitFailed("Failed to download the version description. Try again.");
|
||||
}
|
||||
|
||||
void OneSixUpdate::assetIndexStart()
|
||||
{
|
||||
setStatus("Updating asset index.");
|
||||
OneSixInstance *inst = (OneSixInstance *)m_inst;
|
||||
std::shared_ptr<OneSixVersion> version = inst->getFullVersion();
|
||||
QString assetName = version->assets;
|
||||
QUrl indexUrl("https://s3.amazonaws.com/Minecraft.Download/indexes/" + assetName + ".json");
|
||||
QString localPath = assetName + ".json";
|
||||
auto job = new NetJob("Asset index for " + inst->name());
|
||||
|
||||
auto metacache = MMC->metacache();
|
||||
auto entry = metacache->resolveEntry("asset_indexes", localPath);
|
||||
job->addNetAction(CacheDownload::make(indexUrl, entry));
|
||||
jarlibDownloadJob.reset(job);
|
||||
|
||||
connect(jarlibDownloadJob.get(), SIGNAL(succeeded()), SLOT(assetIndexFinished()));
|
||||
connect(jarlibDownloadJob.get(), SIGNAL(failed()), SLOT(assetIndexFailed()));
|
||||
connect(jarlibDownloadJob.get(), SIGNAL(progress(qint64, qint64)),
|
||||
SIGNAL(progress(qint64, qint64)));
|
||||
|
||||
jarlibDownloadJob->start();
|
||||
}
|
||||
|
||||
void OneSixUpdate::assetIndexFinished()
|
||||
{
|
||||
AssetsIndex index;
|
||||
|
||||
OneSixInstance *inst = (OneSixInstance *)m_inst;
|
||||
std::shared_ptr<OneSixVersion> version = inst->getFullVersion();
|
||||
QString assetName = version->assets;
|
||||
|
||||
QString asset_fname = "assets/indexes/" + assetName + ".json";
|
||||
if (!AssetsUtils::loadAssetsIndexJson(asset_fname, &index))
|
||||
{
|
||||
emitFailed("Failed to read the assets index!");
|
||||
}
|
||||
|
||||
QList<Md5EtagDownloadPtr> dls;
|
||||
for (auto object : index.objects.values())
|
||||
{
|
||||
QString objectName = object.hash.left(2) + "/" + object.hash;
|
||||
QFileInfo objectFile("assets/objects/" + objectName);
|
||||
if ((!objectFile.isFile()) || (objectFile.size() != object.size))
|
||||
{
|
||||
auto objectDL = MD5EtagDownload::make(
|
||||
QUrl("http://resources.download.minecraft.net/" + objectName),
|
||||
objectFile.filePath());
|
||||
dls.append(objectDL);
|
||||
/*
|
||||
Downloadable downloadable = new AssetDownloadable(
|
||||
proxy, new URL("http://resources.download.minecraft.net/" + filename), file,
|
||||
false, object.getHash(), object.getSize());
|
||||
downloadable.setExpectedSize(object.getSize());
|
||||
result.add(downloadable);
|
||||
*/
|
||||
}
|
||||
}
|
||||
if(dls.size())
|
||||
{
|
||||
auto job = new NetJob("Assets for " + inst->name());
|
||||
for(auto dl: dls)
|
||||
job->addNetAction(dl);
|
||||
jarlibDownloadJob.reset(job);
|
||||
connect(jarlibDownloadJob.get(), SIGNAL(succeeded()), SLOT(assetsFinished()));
|
||||
connect(jarlibDownloadJob.get(), SIGNAL(failed()), SLOT(assetsFailed()));
|
||||
connect(jarlibDownloadJob.get(), SIGNAL(progress(qint64, qint64)),
|
||||
SIGNAL(progress(qint64, qint64)));
|
||||
jarlibDownloadJob->start();
|
||||
return;
|
||||
}
|
||||
assetsFinished();
|
||||
}
|
||||
|
||||
void OneSixUpdate::assetIndexFailed()
|
||||
{
|
||||
emitFailed("Failed to download the assets index!");
|
||||
}
|
||||
|
||||
void OneSixUpdate::assetsFinished()
|
||||
{
|
||||
prepareForLaunch();
|
||||
}
|
||||
|
||||
void OneSixUpdate::assetsFailed()
|
||||
{
|
||||
emitFailed("Failed to download assets!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OneSixUpdate::jarlibStart()
|
||||
{
|
||||
setStatus("Getting the library files from Mojang.");
|
||||
@ -215,7 +306,7 @@ void OneSixUpdate::jarlibStart()
|
||||
targetstr += version->id + "/" + version->id + ".jar";
|
||||
|
||||
auto job = new NetJob("Libraries for instance " + inst->name());
|
||||
job->addNetAction(FileDownload::make(QUrl(urlstr), targetstr));
|
||||
job->addNetAction(MD5EtagDownload::make(QUrl(urlstr), targetstr));
|
||||
jarlibDownloadJob.reset(job);
|
||||
|
||||
auto libs = version->getActiveNativeLibs();
|
||||
@ -265,7 +356,7 @@ void OneSixUpdate::jarlibStart()
|
||||
|
||||
void OneSixUpdate::jarlibFinished()
|
||||
{
|
||||
prepareForLaunch();
|
||||
assetIndexStart();
|
||||
}
|
||||
|
||||
void OneSixUpdate::jarlibFailed()
|
||||
|
Reference in New Issue
Block a user