Browse Source

Add more logging to mod downloading process

Ivan Savenko 2 years ago
parent
commit
e4aa981925

+ 2 - 2
launcher/modManager/cmodlistview_moc.cpp

@@ -764,10 +764,10 @@ void CModListView::installMods(QStringList archives)
 		enableMod(mod);
 	}
 
+	checkManagerErrors();
+
 	for(QString archive : archives)
 		QFile::remove(archive);
-
-	checkManagerErrors();
 }
 
 void CModListView::on_refreshButton_clicked()

+ 5 - 0
launcher/modManager/cmodmanager.cpp

@@ -39,6 +39,11 @@ QString detectModArchive(QString path, QString modName)
 			}
 		}
 	}
+
+	logGlobal->error("Failed to detect mod path in archive!");
+	logGlobal->debug("List of file in archive:");
+	for(auto file : files)
+		logGlobal->debug("%s", file.c_str());
 	
 	return "";
 }

+ 22 - 2
lib/filesystem/CZipLoader.cpp

@@ -157,7 +157,15 @@ std::vector<std::string> ZipArchive::listFiles(const boost::filesystem::path & f
 
 	unzFile file = unzOpen2_64(filename.c_str(), FileStream::GetMinizipFilefunc());
 
-	if (unzGoToFirstFile(file) == UNZ_OK)
+	if (file == nullptr)
+	{
+		logGlobal->error("Failed to open file '%s'! Unable to list files!", filename.string());
+		return {};
+	}
+
+	int result = unzGoToFirstFile(file);
+
+	if (result == UNZ_OK)
 	{
 		do
 		{
@@ -171,9 +179,21 @@ std::vector<std::string> ZipArchive::listFiles(const boost::filesystem::path & f
 			unzGetCurrentFileInfo64(file, &info, zipFilename.data(), static_cast<uLong>(zipFilename.size()), nullptr, 0, nullptr, 0);
 
 			ret.emplace_back(zipFilename.data(), zipFilename.size());
+
+			result = unzGoToNextFile(file);
+		}
+		while (result == UNZ_OK);
+
+		if (result != UNZ_OK && result != UNZ_END_OF_LIST_OF_FILE)
+		{
+			logGlobal->error("Failed to list file from '%s'! Error code %d", filename.string(), result);
 		}
-		while (unzGoToNextFile(file) == UNZ_OK);
 	}
+	else
+	{
+		logGlobal->error("Failed to list files from '%s'! Error code %d", filename.string(), result);
+	}
+
 	unzClose(file);
 
 	return ret;