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/b0b9fa57a1c162f3281811700b70c6373a8b8= a17 diff --git a/resources/maildir/maildirresource.cpp b/resources/maildir/mail= dirresource.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 =3D maildirPathForCollection( col ); @@ -140,6 +142,9 @@ MaildirResource::MaildirResource( const QString &id ) } else { synchronizeCollectionTree(); } + + mChangedCleanerTimer =3D new QTimer( this ); + connect( mChangedCleanerTimer, SIGNAL( timeout() ), this, SLOT( changedC= leaner() ) ); } = void MaildirResource::attemptConfigRestoring( KJob * job ) @@ -282,6 +287,7 @@ void MaildirResource::itemAdded( const Akonadi::Item & = item, const Akonadi::Coll = const QString rid =3D 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 QSetstart( CLEANER_TIMEOUT ); } else { restartMaildirScan( dir ); cancelTask( i18n( "Maildir resource got a non-mail content!" )= ); @@ -415,6 +422,7 @@ void MaildirResource::itemMoved( const Item &item, cons= t Collection &source, con const QString newRid =3D 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/maildi= rresource.h index 8445100..95e6112 100644 --- a/resources/maildir/maildirresource.h +++ b/resources/maildir/maildirresource.h @@ -23,6 +23,7 @@ #include #include = +class QTimer; class QFileInfo; class KDirWatch; namespace Akonadi_Maildir_Resource @@ -78,6 +79,7 @@ class MaildirResource : public Akonadi::ResourceBase, pub= lic 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 mMaildirsForCollection; QSet mChangedFiles; //files changed by the resource and that = should be ignored in slotFileChanged - + QTimer *mChangedCleanerTimer; }; = #endif