Skip to content
This repository has been archived by the owner on Aug 26, 2020. It is now read-only.

Commit

Permalink
Really fix new log name handling. Honest. But untested.
Browse files Browse the repository at this point in the history
  • Loading branch information
3vi1 committed Mar 22, 2018
1 parent 371f93b commit 440f822
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/imp.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 10 additions & 6 deletions src/logcatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -166,22 +169,23 @@ 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<QFileInfo> 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.
if ((lastInfoList.size() == 0 ||
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();
Expand Down
4 changes: 2 additions & 2 deletions src/meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<span style=\" color:#0000ff;\">";
QString styleFooter1 = "</span>";
Expand Down

0 comments on commit 440f822

Please sign in to comment.