Fix expiry when set to zero days

Improve logging of expiry job
pull/21/head
Timothy Pearson 12 years ago
parent f820c4f925
commit a4c62fbcea

@ -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 ) );
}
}

Loading…
Cancel
Save