Fix log sorting

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad 2025-04-28 10:28:57 +01:00
parent 111cdc240e
commit 20626e6606
No known key found for this signature in database
GPG Key ID: 5E39D70B4C93C38E
2 changed files with 9 additions and 11 deletions

View File

@ -1057,7 +1057,7 @@ MessageLevel::Enum MinecraftInstance::guessLevel(const QString& line, MessageLev
QStringList MinecraftInstance::getLogFileSearchPaths() QStringList MinecraftInstance::getLogFileSearchPaths()
{ {
return { FS::PathCombine(gameRoot(), "logs"), FS::PathCombine(gameRoot(), "crash-reports"), gameRoot() }; return { FS::PathCombine(gameRoot(), "crash-reports"), FS::PathCombine(gameRoot(), "logs"), gameRoot() };
} }
QString MinecraftInstance::getStatusbarDescription() QString MinecraftInstance::getStatusbarDescription()

View File

@ -146,6 +146,7 @@ void OtherLogsPage::populateSelectLogBox()
ui->selectLogBox->setCurrentIndex(index); ui->selectLogBox->setCurrentIndex(index);
ui->selectLogBox->blockSignals(false); ui->selectLogBox->blockSignals(false);
setControlsEnabled(true); setControlsEnabled(true);
// don't refresh file
return; return;
} else { } else {
setControlsEnabled(false); setControlsEnabled(false);
@ -405,20 +406,17 @@ QStringList OtherLogsPage::getPaths()
QStringList result; QStringList result;
for (QString searchPath : m_logSearchPaths) { for (QString searchPath : m_logSearchPaths) {
QDirIterator iterator(searchPath, QDir::Files | QDir::Readable); QDir searchDir(searchPath);
const bool isRoot = searchPath == m_basePath; QStringList filters{ "*.log", "*.log.gz" };
while (iterator.hasNext()) { if (searchPath != m_basePath)
const QString name = iterator.next(); filters.append("*.txt");
QString relativePath = baseDir.relativeFilePath(name); QStringList entries = searchDir.entryList(filters, QDir::Files | QDir::Readable, QDir::SortFlag::Time);
if (!(name.endsWith(".log") || name.endsWith(".log.gz") || (!isRoot && name.endsWith(".txt")))) for (const QString& name : entries)
continue; result.append(baseDir.relativeFilePath(searchDir.filePath(name)));
result.append(relativePath);
}
} }
return result; return result;