# HG changeset patch # User Chris Cannam # Date 1334665890 -3600 # Node ID 40b40c193eaa6249fcb03b536aab4abf6ac6273e # Parent 0b0444762a5d5d9fc8459cc89b1be2cdf2117206 Fix file update time calculation in FS watcher diff -r 0b0444762a5d -r 40b40c193eaa src/fswatcher.cpp --- a/src/fswatcher.cpp Thu Mar 15 16:27:38 2012 +0000 +++ b/src/fswatcher.cpp Tue Apr 17 13:31:30 2012 +0100 @@ -28,7 +28,7 @@ #include -//#define DEBUG_FSWATCHER 1 +#define DEBUG_FSWATCHER 1 /* * Watching the filesystem is trickier than it seems at first glance. @@ -297,10 +297,10 @@ size_t lastUpdatedAt = m_tokenMap[token]; QSet changed; for (QHash::const_iterator i = m_changes.begin(); - i != m_changes.end(); ++i) { - if (i.value() > lastUpdatedAt) { - changed.insert(i.key()); - } + i != m_changes.end(); ++i) { + if (i.value() > lastUpdatedAt) { + changed.insert(i.key()); + } } m_tokenMap[token] = m_lastCounter; return changed; @@ -321,7 +321,7 @@ if (files == m_dirContents[path]) { #ifdef DEBUG_FSWATCHER - std::cerr << "FsWatcher: Directory " << path << " has changed, but not in a way that we are monitoring" << std::endl; + std::cerr << "FsWatcher: Directory " << path << " has changed, but not in a way that we are monitoring -- doing manual check" << std::endl; #endif #ifdef Q_OS_MAC @@ -371,6 +371,7 @@ bool FsWatcher::manuallyCheckTrackedFiles() { + std::cerr << "FsWatcher::manuallyCheckTrackedFiles" << std::endl; bool foundChanges = false; for (PathTimeMap::iterator i = m_trackedFileUpdates.begin(); @@ -379,9 +380,13 @@ QString path = i.key(); QDateTime prevUpdate = i.value(); - QFileInfo fi(path); + QFileInfo fi(m_workDirPath + QDir::separator() + path); QDateTime currUpdate = fi.lastModified(); +// std::cerr << "FsWatcher: Tracked file " << path << " previously changed at " +// << prevUpdate.toString().toStdString() +// << ", currently at " << currUpdate.toString().toStdString() << std::endl; + if (currUpdate > prevUpdate) { #ifdef DEBUG_FSWATCHER