Detect and report missing local libraries.
This commit is contained in:
		@@ -140,33 +140,32 @@ QString OneSixLibrary::hint() const
 | 
			
		||||
	return m_hint;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool OneSixLibrary::filesExist()
 | 
			
		||||
QStringList OneSixLibrary::files()
 | 
			
		||||
{
 | 
			
		||||
	QStringList retval;
 | 
			
		||||
	QString storage = storagePath();
 | 
			
		||||
	if (storage.contains("${arch}"))
 | 
			
		||||
	{
 | 
			
		||||
		QString cooked_storage = storage;
 | 
			
		||||
		cooked_storage.replace("${arch}", "32");
 | 
			
		||||
		QFileInfo info32(PathCombine("libraries", cooked_storage));
 | 
			
		||||
		if (!info32.exists())
 | 
			
		||||
		{
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		retval.append(PathCombine("libraries", cooked_storage));
 | 
			
		||||
		cooked_storage = storage;
 | 
			
		||||
		cooked_storage.replace("${arch}", "64");
 | 
			
		||||
		QFileInfo info64(PathCombine("libraries", cooked_storage));
 | 
			
		||||
		if (!info64.exists())
 | 
			
		||||
		{
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		retval.append(PathCombine("libraries", cooked_storage));
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
		retval.append(PathCombine("libraries", storage));
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool OneSixLibrary::filesExist()
 | 
			
		||||
{
 | 
			
		||||
	auto libFiles = files();
 | 
			
		||||
	for(auto file: libFiles)
 | 
			
		||||
	{
 | 
			
		||||
		QFileInfo info(PathCombine("libraries", storage));
 | 
			
		||||
		QFileInfo info(file);
 | 
			
		||||
		if (!info.exists())
 | 
			
		||||
		{
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -143,4 +143,5 @@ public:
 | 
			
		||||
 | 
			
		||||
	bool extractTo(QString target_dir);
 | 
			
		||||
	bool filesExist();
 | 
			
		||||
	QStringList files();
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -268,10 +268,16 @@ void OneSixUpdate::jarlibStart()
 | 
			
		||||
 | 
			
		||||
	auto metacache = MMC->metacache();
 | 
			
		||||
	QList<ForgeXzDownloadPtr> ForgeLibs;
 | 
			
		||||
	QList<std::shared_ptr<OneSixLibrary>> brokenLocalLibs;
 | 
			
		||||
 | 
			
		||||
	for (auto lib : libs)
 | 
			
		||||
	{
 | 
			
		||||
		if (lib->hint() == "local")
 | 
			
		||||
		{
 | 
			
		||||
			if(!lib->filesExist())
 | 
			
		||||
				brokenLocalLibs.append(lib);
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		QString raw_storage = lib->storagePath();
 | 
			
		||||
		QString raw_dl = lib->downloadUrl();
 | 
			
		||||
@@ -305,6 +311,18 @@ void OneSixUpdate::jarlibStart()
 | 
			
		||||
			f(raw_storage, raw_dl);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if(!brokenLocalLibs.empty())
 | 
			
		||||
	{
 | 
			
		||||
		jarlibDownloadJob.reset();
 | 
			
		||||
		QStringList failed;
 | 
			
		||||
		for(auto brokenLib : brokenLocalLibs)
 | 
			
		||||
		{
 | 
			
		||||
			failed.append(brokenLib->files());
 | 
			
		||||
		}
 | 
			
		||||
		QString failed_all = failed.join("\n");
 | 
			
		||||
		emitFailed(tr("Some libraries marked as 'local' are missing their jar files:\n%1\n\nYou'll have to correct this problem manually. If this is an externally tracked instance, make sure to run it at least once outside of MultiMC.").arg(failed_all));
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	// 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())
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user