CVS commit by tilladam: Backport from head of: CVS commit by tilladam: Don't do an expunge Folder, thereby removing all mails in an imap folder, when the deleteMessage method is called on a message that does not have a UID, for whatever reason. Ouch. Now we need to find out why the message has no uid. Ingo, backport, I assume? M +15 -2 kmfolderimap.cpp 1.163.2.1 --- kdepim/kmail/kmfolderimap.cpp #1.163:1.163.2.1 @@ -1208,5 +1208,14 @@ void KMFolderImap::deleteMessage(KMMessa KURL url = mAccount->getUrl(); KMFolderImap *msg_parent = static_cast(msg->parent()); - url.setPath(msg_parent->imapPath() + ";UID=" + msg->headerField("X-UID")); + QString uid = msg->headerField("X-UID"); + /* If the uid is empty the delete job below will nuke all mail in the + folder, so we better safeguard against that. See ::expungeFolder, as + to why. :( */ + if ( uid.isEmpty() ) { + kdDebug( 5006 ) << "KMFolderImap::deleteMessage: Attempt to delete " + "an empty UID. Aborting." << endl; + return; + } + url.setPath(msg_parent->imapPath() + ";UID=" + uid ); if ( mAccount->makeConnection() != ImapAccountBase::Connected ) return; @@ -1229,5 +1238,9 @@ void KMFolderImap::deleteMessage(QPtrLis for ( QStringList::Iterator it = sets.begin(); it != sets.end(); ++it ) { - url.setPath(msg_parent->imapPath() + ";UID=" + *it); + QString uid = *it; + // Don't delete with no uid, that nukes the folder. Should not happen, but + // better safe than sorry. + if ( uid.isEmpty() ) continue; + url.setPath(msg_parent->imapPath() + ";UID=" + uid); if ( mAccount->makeConnection() != ImapAccountBase::Connected ) return;