changeset 593:40b40c193eaa

Fix file update time calculation in FS watcher
author Chris Cannam
date Tue, 17 Apr 2012 13:31:30 +0100
parents 0b0444762a5d
children 825a457f6415
files src/fswatcher.cpp
diffstat 1 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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 <deque>
 
-//#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<QString> changed;
     for (QHash<QString, size_t>::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