From e4aa98192556d0fdbd6cf6f500c0c62105a5ee16 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Mon, 11 Sep 2023 18:10:07 +0300 Subject: [PATCH] Add more logging to mod downloading process --- launcher/modManager/cmodlistview_moc.cpp | 4 ++-- launcher/modManager/cmodmanager.cpp | 5 +++++ lib/filesystem/CZipLoader.cpp | 24 ++++++++++++++++++++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/launcher/modManager/cmodlistview_moc.cpp b/launcher/modManager/cmodlistview_moc.cpp index 64481f72a..f0cf46c16 100644 --- a/launcher/modManager/cmodlistview_moc.cpp +++ b/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() diff --git a/launcher/modManager/cmodmanager.cpp b/launcher/modManager/cmodmanager.cpp index 350007a33..656560f75 100644 --- a/launcher/modManager/cmodmanager.cpp +++ b/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 ""; } diff --git a/lib/filesystem/CZipLoader.cpp b/lib/filesystem/CZipLoader.cpp index 3bbbdec3b..b743e92da 100644 --- a/lib/filesystem/CZipLoader.cpp +++ b/lib/filesystem/CZipLoader.cpp @@ -157,7 +157,15 @@ std::vector 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 ZipArchive::listFiles(const boost::filesystem::path & f unzGetCurrentFileInfo64(file, &info, zipFilename.data(), static_cast(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;