Procházet zdrojové kódy

Cache archive files

nordsoft před 2 roky
rodič
revize
18c44fc006
1 změnil soubory, kde provedl 6 přidání a 5 odebrání
  1. 6 5
      launcher/modManager/cmodmanager.cpp

+ 6 - 5
launcher/modManager/cmodmanager.cpp

@@ -22,15 +22,15 @@
 
 
 namespace
 namespace
 {
 {
-QString detectModArchive(QString path, QString modName)
+QString detectModArchive(QString path, QString modName, std::vector<std::string> & filesToExtract)
 {
 {
-	auto files = ZipArchive::listFiles(qstringToPath(path));
+	filesToExtract = ZipArchive::listFiles(qstringToPath(path));
 
 
 	QString modDirName;
 	QString modDirName;
 
 
 	for(int folderLevel : {0, 1}) //search in subfolder if there is no mod.json in the root
 	for(int folderLevel : {0, 1}) //search in subfolder if there is no mod.json in the root
 	{
 	{
-		for(auto file : files)
+		for(auto file : filesToExtract)
 		{
 		{
 			QString filename = QString::fromUtf8(file.c_str());
 			QString filename = QString::fromUtf8(file.c_str());
 			modDirName = filename.section('/', 0, folderLevel);
 			modDirName = filename.section('/', 0, folderLevel);
@@ -275,11 +275,12 @@ bool CModManager::doInstallMod(QString modname, QString archivePath)
 	if(localMods.contains(modname))
 	if(localMods.contains(modname))
 		return addError(modname, "Mod with such name is already installed");
 		return addError(modname, "Mod with such name is already installed");
 
 
-	QString modDirName = ::detectModArchive(archivePath, modname);
+	std::vector<std::string> filesToExtract;
+	QString modDirName = ::detectModArchive(archivePath, modname, filesToExtract);
 	if(!modDirName.size())
 	if(!modDirName.size())
 		return addError(modname, "Mod archive is invalid or corrupted");
 		return addError(modname, "Mod archive is invalid or corrupted");
 
 
-	if(!ZipArchive::extract(qstringToPath(archivePath), qstringToPath(destDir)))
+	if(!ZipArchive::extract(qstringToPath(archivePath), qstringToPath(destDir), filesToExtract))
 	{
 	{
 		removeModDir(destDir + modDirName);
 		removeModDir(destDir + modDirName);
 		return addError(modname, "Failed to extract mod data");
 		return addError(modname, "Failed to extract mod data");