From 440f8227e47b82c3077f81c7421d65023621eafa Mon Sep 17 00:00:00 2001 From: Jesse Litton Date: Thu, 22 Mar 2018 07:53:19 -0500 Subject: [PATCH] Really fix new log name handling. Honest. But untested. --- src/imp.pro | 2 +- src/logcatcher.cpp | 16 ++++++++++------ src/meta.h | 4 ++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/imp.pro b/src/imp.pro index 5550602..69fb9cc 100644 --- a/src/imp.pro +++ b/src/imp.pro @@ -13,7 +13,7 @@ QT += xml xmlpatterns svg widgets TARGET = imp TEMPLATE = app -VERSION = 0.9.7.3 +VERSION = 0.9.7.4 QMAKE_TARGET_COMPANY = EternalDusk QMAKE_TARGET_DESCRIPTION = Eve Online Intelligence Management Program QMAKE_TARGET_COPYRIGHT = (c) Copyright 2016-2017 Jesse Litton diff --git a/src/logcatcher.cpp b/src/logcatcher.cpp index 77c54d0..d0d542c 100644 --- a/src/logcatcher.cpp +++ b/src/logcatcher.cpp @@ -143,13 +143,16 @@ void LogCatcher::findCurrentLogs(const QString& dirName) infoList.clear(); } - QRegExp logNameRegEx("(.*)( \\[[0-9]+\\])?_[0-9]+_[0-9]+\\.txt$"); + QRegularExpression logName_re("(.*?)( \\[\\d+\\])?_[0-9]+_[0-9]+\\.txt$"); foreach (QFileInfo fileInfo, QDir(dirName).entryInfoList()) { if (fileInfo.isFile()) { + qDebug() << "LogCatcher::findCurrentLogs: fileName = " << fileInfo.fileName(); + // If filename doesn't look like a log, skip it. - if (logNameRegEx.indexIn(fileInfo.fileName()) == -1) + QRegularExpressionMatch logMatch = logName_re.match(fileInfo.fileName()); + if (!logMatch.hasMatch()) { continue; } @@ -166,14 +169,15 @@ void LogCatcher::findCurrentLogs(const QString& dirName) // not - which means they logged on a second character, creating a newer // file, then logged that character out. - QString channelName = logNameRegEx.cap(1); + QString channelName = logMatch.captured(1); //logNameRegEx.cap(1); if(!localChannels.contains(channelName)) { QMutableListIterator i(infoList); while (i.hasNext()) { QString iFileName = i.next().fileName(); - QString iChanName = iFileName.left(iFileName.length() - 20); - if (iChanName == channelName) + QRegularExpressionMatch match = logName_re.match(iFileName); + + if (match.hasPartialMatch() && match.captured(0) == channelName) { // If file has changed and file is newer than what we already // have in list, remove what we previously put in list. @@ -181,7 +185,7 @@ void LogCatcher::findCurrentLogs(const QString& dirName) compareLastFileSize(fileInfo, lastInfoList)) && (i.value().lastModified() < fileInfo.lastModified())) { - qDebug() << "LogCatcher::findCurrentLogs: Found newer or changed log for " << iChanName; + qDebug() << "LogCatcher::findCurrentLogs: Found newer or changed log for " << match.captured(0); qDebug() << " ignoring " << iFileName; qDebug() << " in favor of " << fileInfo.fileName(); i.remove(); diff --git a/src/meta.h b/src/meta.h index e55d47a..677ebbc 100644 --- a/src/meta.h +++ b/src/meta.h @@ -27,8 +27,8 @@ static const struct Version { Version(){} - QString release = "0.9.7.3"; //VERSION; - QString name = "Relatively Sane Clown Posse"; + QString release = "0.9.7.4"; //VERSION; + QString name = "Second Time's the Charred"; QString styleHeader1 = ""; QString styleFooter1 = "";