diff --git a/src/engine/documenttimedb.h b/src/engine/documenttimedb.h --- a/src/engine/documenttimedb.h +++ b/src/engine/documenttimedb.h @@ -39,9 +39,17 @@ static MDB_dbi create(MDB_txn* txn); static MDB_dbi open(MDB_txn* txn); - struct TimeInfo { - quint32 mTime; - quint32 cTime; + struct TimeInfo + { + /** Tracking of file time stamps + * + * @sa QDateTime::toTime_t() + * @sa QFileInfo::lastModified() + * @sa QFileInfo::metadataChangeTime() + */ + quint32 mTime; /**< file (data) modification time */ + quint32 cTime; /**< metadata (e.g. XAttr) change time */ + /* No birthtime yet */ explicit TimeInfo(quint32 mt = 0, quint32 ct = 0) : mTime(mt), cTime(ct) {} diff --git a/src/file/basicindexingjob.cpp b/src/file/basicindexingjob.cpp --- a/src/file/basicindexingjob.cpp +++ b/src/file/basicindexingjob.cpp @@ -65,7 +65,7 @@ tg.indexFileNameText(fileName, QByteArray("F")); tg.indexText(m_mimetype, QByteArray("M")); - // Time + // (Content) Modification time, Metadata (e.g. XAttr) change time doc.setMTime(statBuf.st_mtime); doc.setCTime(statBuf.st_ctime); diff --git a/src/file/modifiedfileindexer.cpp b/src/file/modifiedfileindexer.cpp --- a/src/file/modifiedfileindexer.cpp +++ b/src/file/modifiedfileindexer.cpp @@ -66,18 +66,25 @@ continue; } - quint32 mTime = tr.documentTimeInfo(fileId).mTime; + DocumentTimeDB::TimeInfo timeInfo = tr.documentTimeInfo(fileId); // A folders mtime is updated when a new file is added / removed / renamed // we don't really need to reindex a folder when that happens // In fact, we never need to reindex a folder - if (mTime && mimetype == QLatin1String("inode/directory")) { + if (timeInfo.mTime && mimetype == QLatin1String("inode/directory")) { continue; } // FIXME: Using QFileInfo over here is quite expensive! QFileInfo fileInfo(filePath); - if (mTime == fileInfo.lastModified().toTime_t()) { + bool mTimeChanged = timeInfo.mTime != fileInfo.lastModified().toTime_t(); +#if QT_VERSION >= QT_VERSION_CHECK(5,10,0) + bool cTimeChanged = timeInfo.cTime != fileInfo.metadataChangeTime().toTime_t(); +#else + bool cTimeChanged = timeInfo.cTime != fileInfo.created().toTime_t(); +#endif + + if (!mTimeChanged && !cTimeChanged) { continue; } diff --git a/src/file/unindexedfileiterator.cpp b/src/file/unindexedfileiterator.cpp --- a/src/file/unindexedfileiterator.cpp +++ b/src/file/unindexedfileiterator.cpp @@ -22,6 +22,7 @@ #include "fileindexerconfig.h" #include "idutils.h" #include "transaction.h" +#include "baloodebug.h" #include #include @@ -113,11 +114,19 @@ m_mTimeChanged = true; } - if (timeInfo.cTime != fileInfo.created().toTime_t()) { +#if QT_VERSION >= QT_VERSION_CHECK(5,10,0) + auto fileMTime = fileInfo.metadataChangeTime().toTime_t(); +#else + auto fileMTime = fileInfo.created().toTime_t(); +#endif + if (timeInfo.cTime != fileMTime) { m_cTimeChanged = true; } if (m_mTimeChanged || m_cTimeChanged) { + qCDebug(BALOO) << "mtime/ctime changed:" + << timeInfo.mTime << fileInfo.lastModified().toTime_t() + << timeInfo.cTime << fileMTime; return true; }