From kde-commits Sat Nov 23 15:21:54 2013 From: Andras Mantia Date: Sat, 23 Nov 2013 15:21:54 +0000 To: kde-commits Subject: [kdepim-runtime/KDE/4.12] resources/maildir: Clean the changed file structures after a while in case Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=138522012331901 Git commit 7ffc765db397a24dad96d3cbe2c758095baa5a80 by Andras Mantia. Committed on 17/11/2013 at 10:52. Pushed by amantia into branch 'KDE/4.12'. Clean the changed file structures after a while in case the FS notification= works as expected. (cherry picked from commit b0b9fa57a1c162f3281811700b70c6373a8b8a17) Conflicts: resources/maildir/maildirresource.cpp M +13 -0 resources/maildir/maildirresource.cpp M +3 -1 resources/maildir/maildirresource.h http://commits.kde.org/kdepim-runtime/7ffc765db397a24dad96d3cbe2c758095baa5= a80 diff --git a/resources/maildir/maildirresource.cpp b/resources/maildir/mail= dirresource.cpp index 68a9506..569c45f 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 ) @@ -283,6 +288,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 ); = restartMaildirScan( dir ); = @@ -357,6 +363,7 @@ void MaildirResource::itemChanged( const Akonadi::Item&= item, const QSetstart( CLEANER_TIMEOUT ); } else { restartMaildirScan( dir ); cancelTask( i18n( "Error: Unsupported type." ) ); @@ -403,6 +410,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 ); @@ -847,4 +855,9 @@ void MaildirResource::restartMaildirScan(const Maildir = &maildir) mFsWatcher->restartDirScan( path + QLatin1Literal( "/cur" ) ); } = +void MaildirResource::changedCleaner() +{ + mChangedFiles.clear(); +} + #include "maildirresource.moc" 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