Improved delete

This commit is contained in:
M66B 2019-06-14 10:12:08 +02:00
parent 5d830c2d16
commit 48a348fcff
1 changed files with 26 additions and 18 deletions

View File

@ -590,24 +590,32 @@ class Core {
// Delete message // Delete message
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
Message[] imessages; if (message.uid != null) {
if (TextUtils.isEmpty(message.msgid)) Message iexisting = ifolder.getMessageByUID(message.uid);
if (message.uid == null) if (iexisting == null)
throw new IllegalArgumentException("Delete without ID"); Log.w(folder.name + " existing not found uid=" + message.uid);
else {
Message imessage = ifolder.getMessageByUID(message.uid);
if (imessage == null)
throw new MessageRemovedException();
imessages = new Message[]{imessage};
}
else else
imessages = ifolder.search(new MessageIDTerm(message.msgid));
for (Message imessage : imessages) {
Log.i(folder.name + " deleting uid=" + message.uid + " msgid=" + message.msgid);
try { try {
imessage.setFlag(Flags.Flag.DELETED, true); Log.i(folder.name + " deleting uid=" + message.uid);
iexisting.setFlag(Flags.Flag.DELETED, true);
} catch (MessageRemovedException ignored) { } catch (MessageRemovedException ignored) {
Log.w(folder.name + " existing gone uid=" + message.uid);
}
}
if (!TextUtils.isEmpty(message.msgid)) {
Message[] imessages = ifolder.search(new MessageIDTerm(message.msgid));
if (imessages == null)
Log.w(folder.name + " search for msgid=" + message.msgid + " returned null");
else
for (Message iexisting : imessages) {
long muid = ifolder.getUID(iexisting);
Log.i(folder.name + " deleting uid=" + muid);
try {
iexisting.setFlag(Flags.Flag.DELETED, true);
} catch (MessageRemovedException ignored) {
Log.w(folder.name + " existing gone uid=" + muid);
}
} }
} }