[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE_3_2_BRANCH: kdepim/kmail
From:       Till Adam <adam () kde ! org>
Date:       2004-02-04 8:56:46
Message-ID: 20040204085646.6274098E1 () office ! kde ! org
[Download RAW message or body]

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<KMFolderImap*>(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;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic