NOISSUE refactor *Download into more, smaller pieces
* Download is now Download. * Download uses Sink subclasses to process various events. * Validators can be used to further customize the Sink behaviour.
This commit is contained in:
		@@ -397,7 +397,7 @@ protected:
 | 
			
		||||
		if (entry->isStale())
 | 
			
		||||
		{
 | 
			
		||||
			NetJob *fjob = new NetJob("Forge download");
 | 
			
		||||
			fjob->addNetAction(CacheDownload::make(forgeVersion->url(), entry));
 | 
			
		||||
			fjob->addNetAction(Net::Download::makeCached(forgeVersion->url(), entry));
 | 
			
		||||
			connect(fjob, &NetJob::progress, this, &Task::setProgress);
 | 
			
		||||
			connect(fjob, &NetJob::status, this, &Task::setStatus);
 | 
			
		||||
			connect(fjob, &NetJob::failed, [this](QString reason)
 | 
			
		||||
 
 | 
			
		||||
@@ -131,10 +131,8 @@ void ForgeListLoadTask::executeTask()
 | 
			
		||||
	forgeListEntry->setStale(true);
 | 
			
		||||
	gradleForgeListEntry->setStale(true);
 | 
			
		||||
 | 
			
		||||
	job->addNetAction(listDownload = CacheDownload::make(QUrl(URLConstants::FORGE_LEGACY_URL),
 | 
			
		||||
														 forgeListEntry));
 | 
			
		||||
	job->addNetAction(gradleListDownload = CacheDownload::make(
 | 
			
		||||
						  QUrl(URLConstants::FORGE_GRADLE_URL), gradleForgeListEntry));
 | 
			
		||||
	job->addNetAction(listDownload = Net::Download::makeCached(QUrl(URLConstants::FORGE_LEGACY_URL),forgeListEntry));
 | 
			
		||||
	job->addNetAction(gradleListDownload = Net::Download::makeCached(QUrl(URLConstants::FORGE_GRADLE_URL), gradleForgeListEntry));
 | 
			
		||||
 | 
			
		||||
	connect(listDownload.get(), SIGNAL(failed(int)), SLOT(listFailed()));
 | 
			
		||||
	connect(gradleListDownload.get(), SIGNAL(failed(int)), SLOT(gradleListFailed()));
 | 
			
		||||
@@ -154,15 +152,14 @@ bool ForgeListLoadTask::parseForgeList(QList<BaseVersionPtr> &out)
 | 
			
		||||
{
 | 
			
		||||
	QByteArray data;
 | 
			
		||||
	{
 | 
			
		||||
		auto dlJob = listDownload;
 | 
			
		||||
		auto filename = std::dynamic_pointer_cast<CacheDownload>(dlJob)->getTargetFilepath();
 | 
			
		||||
		auto filename = listDownload->getTargetFilepath();
 | 
			
		||||
		QFile listFile(filename);
 | 
			
		||||
		if (!listFile.open(QIODevice::ReadOnly))
 | 
			
		||||
		{
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		data = listFile.readAll();
 | 
			
		||||
		dlJob.reset();
 | 
			
		||||
		listDownload.reset();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	QJsonParseError jsonError;
 | 
			
		||||
@@ -266,15 +263,14 @@ bool ForgeListLoadTask::parseForgeGradleList(QList<BaseVersionPtr> &out)
 | 
			
		||||
	QMap<int, std::shared_ptr<ForgeVersion>> lookup;
 | 
			
		||||
	QByteArray data;
 | 
			
		||||
	{
 | 
			
		||||
		auto dlJob = gradleListDownload;
 | 
			
		||||
		auto filename = std::dynamic_pointer_cast<CacheDownload>(dlJob)->getTargetFilepath();
 | 
			
		||||
		auto filename = gradleListDownload->getTargetFilepath();
 | 
			
		||||
		QFile listFile(filename);
 | 
			
		||||
		if (!listFile.open(QIODevice::ReadOnly))
 | 
			
		||||
		{
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		data = listFile.readAll();
 | 
			
		||||
		dlJob.reset();
 | 
			
		||||
		gradleListDownload.reset();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	QJsonParseError jsonError;
 | 
			
		||||
 
 | 
			
		||||
@@ -81,8 +81,8 @@ protected:
 | 
			
		||||
	NetJobPtr listJob;
 | 
			
		||||
	ForgeVersionList *m_list;
 | 
			
		||||
 | 
			
		||||
	CacheDownloadPtr listDownload;
 | 
			
		||||
	CacheDownloadPtr gradleListDownload;
 | 
			
		||||
	Net::Download::Ptr listDownload;
 | 
			
		||||
	Net::Download::Ptr gradleListDownload;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	bool parseForgeList(QList<BaseVersionPtr> &out);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user