Commit 53daeb84 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Fix deletion of two (or more) attachments

Deleting the first attachment triggers an update of the message. In case
of IMAP this is done by adding a new message and deleting the old one.
This changes the remote id of the message. The problem was that after
deleting the second attachment the update of the message tried to set
the old remote id. This fails because only the server can set a remote id.
This problem is fixed by clearing the remote id before starting an
ItemModifyJob.

Funded by: Intevation GmbH

BUG: 282792
FIXED-IN: 5.18.0
parent b467d452
Pipeline #61471 passed with stage
in 38 minutes and 57 seconds
...@@ -399,6 +399,10 @@ bool ViewerPrivate::deleteAttachment(KMime::Content *node, bool showWarning) ...@@ -399,6 +399,10 @@ bool ViewerPrivate::deleteAttachment(KMime::Content *node, bool showWarning)
KMime::Message *modifiedMessage = mNodeHelper->messageWithExtraContent(mMessage.data()); KMime::Message *modifiedMessage = mNodeHelper->messageWithExtraContent(mMessage.data());
mMimePartTree->mimePartModel()->setRoot(modifiedMessage); mMimePartTree->mimePartModel()->setRoot(modifiedMessage);
mMessageItem.setPayloadFromData(mMessage->encodedContent()); mMessageItem.setPayloadFromData(mMessage->encodedContent());
// Modifying the payload might change the remote id (e.g. for IMAP) of the item, so don't try to force on it
// a potentially old remote id. Without clearing the remote id, deleting multiple attachments from a message
// stored on an IMAP server will likely fail with "Invalid attempt to modify the remoteID for item [...]".
mMessageItem.setRemoteId({});
auto job = new Akonadi::ItemModifyJob(mMessageItem, mSession); auto job = new Akonadi::ItemModifyJob(mMessageItem, mSession);
job->disableRevisionCheck(); job->disableRevisionCheck();
connect(job, &KJob::result, this, &ViewerPrivate::itemModifiedResult); connect(job, &KJob::result, this, &ViewerPrivate::itemModifiedResult);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment