[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepim-runtime] resources/maildir: Clean the changed file structures after a while in case the FS n
From:       Andras Mantia <amantia () kde ! org>
Date:       2013-11-17 10:52:31
Message-ID: E1Vhzxv-0002vZ-1z () scm ! kde ! org
[Download RAW message or body]

Git commit b0b9fa57a1c162f3281811700b70c6373a8b8a17 by Andras Mantia.
Committed on 17/11/2013 at 10:52.
Pushed by amantia into branch 'master'.

Clean the changed file structures after a while in case the FS notification works as \
expected.

M  +12   -0    resources/maildir/maildirresource.cpp
M  +3    -1    resources/maildir/maildirresource.h

http://commits.kde.org/kdepim-runtime/b0b9fa57a1c162f3281811700b70c6373a8b8a17

diff --git a/resources/maildir/maildirresource.cpp \
b/resources/maildir/maildirresource.cpp index 3cfee66..834f6ae 100644
--- a/resources/maildir/maildirresource.cpp
+++ b/resources/maildir/maildirresource.cpp
@@ -52,6 +52,8 @@ using namespace Akonadi;
 using KPIM::Maildir;
 using namespace Akonadi_Maildir_Resource;
 
+#define CLEANER_TIMEOUT 2*6000
+
 Maildir MaildirResource::maildirForCollection( const Collection& col )
 {
   const QString path = maildirPathForCollection( col );
@@ -140,6 +142,9 @@ MaildirResource::MaildirResource( const QString &id )
   } else {
      synchronizeCollectionTree();
   }
+
+  mChangedCleanerTimer = new QTimer( this );
+  connect( mChangedCleanerTimer, SIGNAL( timeout() ), this, SLOT( changedCleaner() ) \
);  }
 
 void MaildirResource::attemptConfigRestoring( KJob * job )
@@ -282,6 +287,7 @@ void MaildirResource::itemAdded( const Akonadi::Item & item, \
const Akonadi::Coll  
     const QString rid = dir.addEntry( mail->encodedContent() );
     mChangedFiles.insert( rid );
+    mChangedCleanerTimer->start( CLEANER_TIMEOUT );
 
     if ( rid.isEmpty() ) {
       restartMaildirScan( dir );
@@ -370,6 +376,7 @@ void MaildirResource::itemChanged( const Akonadi::Item& item, \
const QSet<QByteAr  return;
           }
           mChangedFiles.insert( newItem.remoteId() );
+          mChangedCleanerTimer->start( CLEANER_TIMEOUT );
         } else {
             restartMaildirScan( dir );
             cancelTask( i18n( "Maildir resource got a non-mail content!" ) );
@@ -415,6 +422,7 @@ void MaildirResource::itemMoved( const Item &item, const \
Collection &source, con  const QString newRid = sourceDir.moveEntryTo( \
item.remoteId(), destDir );  
   mChangedFiles.insert( newRid );
+  mChangedCleanerTimer->start( CLEANER_TIMEOUT );
 
   restartMaildirScan( sourceDir );
   restartMaildirScan( destDir );
@@ -858,3 +866,7 @@ void MaildirResource::restartMaildirScan(const Maildir &maildir)
     mFsWatcher->restartDirScan( path + QLatin1Literal( "/cur" ) );
 }
 
+void MaildirResource::changedCleaner()
+{
+    mChangedFiles.clear();
+}
diff --git a/resources/maildir/maildirresource.h \
b/resources/maildir/maildirresource.h index 8445100..95e6112 100644
--- a/resources/maildir/maildirresource.h
+++ b/resources/maildir/maildirresource.h
@@ -23,6 +23,7 @@
 #include <akonadi/collection.h>
 #include <akonadi/resourcebase.h>
 
+class QTimer;
 class QFileInfo;
 class KDirWatch;
 namespace Akonadi_Maildir_Resource
@@ -78,6 +79,7 @@ class MaildirResource : public Akonadi::ResourceBase, public \
Akonadi::AgentBase:  void fsWatchFileModifyResult( KJob* job );
     // Try to restore some config values from Akonadi data
     void attemptConfigRestoring( KJob* job );
+    void changedCleaner();
 
   private:
     bool ensureDirExists();
@@ -97,7 +99,7 @@ private:
     KDirWatch *mFsWatcher;
     QHash<QString, KPIM::Maildir> mMaildirsForCollection;
     QSet<QString> mChangedFiles; //files changed by the resource and that should be \
                ignored in slotFileChanged
-
+    QTimer *mChangedCleanerTimer;
 };
 
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic