From a4c62fbcea26b13c3c9f1a6a306960809dfe831a Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Mon, 27 Aug 2012 22:05:42 -0500 Subject: Fix expiry when set to zero days Improve logging of expiry job --- kmail/expirejob.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'kmail') diff --git a/kmail/expirejob.cpp b/kmail/expirejob.cpp index a208b918..be5003b3 100644 --- a/kmail/expirejob.cpp +++ b/kmail/expirejob.cpp @@ -79,17 +79,17 @@ void ExpireJob::kill() void ExpireJob::execute() { - mMaxUnreadTime = 0; - mMaxReadTime = 0; + mMaxUnreadTime = -1; + mMaxReadTime = -1; mCurrentIndex = 0; int unreadDays, readDays; mSrcFolder->daysToExpire( unreadDays, readDays ); - if (unreadDays > 0) { + if (unreadDays >= 0) { kdDebug(5006) << "ExpireJob: deleting unread older than "<< unreadDays << " days" << endl; mMaxUnreadTime = time(0) - unreadDays * 3600 * 24; } - if (readDays > 0) { + if (readDays >= 0) { kdDebug(5006) << "ExpireJob: deleting read older than "<< readDays << " days" << endl; mMaxReadTime = time(0) - readDays * 3600 * 24; } @@ -123,15 +123,28 @@ void ExpireJob::slotDoWork() #endif for( ; mCurrentIndex >= stopIndex; mCurrentIndex-- ) { const KMMsgBase *mb = storage->getMsgBase( mCurrentIndex ); +#ifdef DEBUG_SCHEDULER + kdDebug(5006) << "ExpireJob: checking message " << mCurrentIndex << " existence" << endl; +#endif if (mb == 0) continue; +#ifdef DEBUG_SCHEDULER + kdDebug(5006) << "ExpireJob: checking message " << mCurrentIndex << " importance" << endl; +#endif if ( ( mb->isImportant() || mb->isTodo() || mb->isWatched() ) && GlobalSettings::self()->excludeImportantMailFromExpiry() ) continue; +#ifdef DEBUG_SCHEDULER + kdDebug(5006) << "ExpireJob: checking message " << mCurrentIndex << " time" << endl; +#endif time_t maxTime = mb->isUnread() ? mMaxUnreadTime : mMaxReadTime; +#ifdef DEBUG_SCHEDULER + kdDebug(5006) << "ExpireJob: checking message " << mCurrentIndex << " time (" << mb->date() << " vs " << maxTime << ")" << endl; +#endif if (mb->date() < maxTime) { + kdDebug(5006) << "ExpireJob: expiring message " << mCurrentIndex << " from folder " << mSrcFolder->location() << endl; mRemovedMsgs.append( storage->getMsgBase( mCurrentIndex ) ); } } -- cgit v1.2.3