Added fail safes

pull/194/merge
M66B 3 years ago
parent 0f07b6a4d8
commit 56d7d6d951

@ -743,7 +743,8 @@ class Core {
Message[] imessages = findMsgId(context, account, ifolder, msgid);
if (imessages != null)
for (Message iexisting : imessages) {
for (Message iexisting : imessages)
try {
long muid = ifolder.getUID(iexisting);
if (muid < 0)
continue;
@ -751,6 +752,8 @@ class Core {
// RFC3501: Unique identifiers are assigned in a strictly ascending fashion
if (uid == null || muid > uid)
uid = muid;
} catch (MessageRemovedException ex) {
Log.w(ex);
}
Log.i(name + " got uid=" + uid + " for msgid=" + msgid);
@ -1131,13 +1134,16 @@ class Core {
if (imessages != null) {
Long found = null;
for (Message iexisting : imessages) {
for (Message iexisting : imessages)
try {
long muid = ifolder.getUID(iexisting);
if (muid < 0)
continue;
Log.i(folder.name + " found added uid=" + muid + " msgid=" + message.msgid);
if (found == null || muid > found)
found = muid;
} catch (MessageRemovedException ex) {
Log.w(ex);
}
if (found != null) {
@ -1145,7 +1151,8 @@ class Core {
newuid = found;
List<Message> delete = new ArrayList<>();
for (Message iexisting : imessages) {
for (Message iexisting : imessages)
try {
long muid = ifolder.getUID(iexisting);
if (muid < 0)
continue;
@ -1156,6 +1163,8 @@ class Core {
} catch (MessagingException ex) {
Log.w(ex);
}
} catch (MessageRemovedException ex) {
Log.w(ex);
}
expunge(context, ifolder, delete);
@ -1598,29 +1607,27 @@ class Core {
(!found || EntityFolder.DRAFTS.equals(folder.type)))
try {
Message[] imessages = findMsgId(context, account, ifolder, message.msgid);
if (imessages == null)
Log.w(folder.name + " search for msgid=" + message.msgid + " returned null");
else
for (Message iexisting : imessages) {
if (imessages != null)
for (Message iexisting : imessages)
try {
long muid = ifolder.getUID(iexisting);
if (found && muid == message.uid)
continue;
// Fail safe
MessageHelper helper = new MessageHelper((MimeMessage) iexisting, context);
if (!message.msgid.equals(helper.getMessageID()))
continue;
Log.i(folder.name + " deleting uid=" + muid);
try {
if (perform_expunge)
iexisting.setFlag(Flags.Flag.DELETED, true);
else
iexisting.setFlag(Flags.Flag.DELETED, message.ui_deleted);
deleted.add(iexisting);
} catch (MessageRemovedException ignored) {
Log.w(folder.name + " existing gone uid=" + muid);
}
} catch (MessageRemovedException ex) {
Log.w(ex);
}
} catch (MessagingException ex) {
Log.w(ex);
@ -2372,10 +2379,13 @@ class Core {
ifolder.fetch(imessages, fp);
List<Message> idelete = new ArrayList<>();
for (Message imessage : imessages) {
for (Message imessage : imessages)
try {
long uid = ifolder.getUID(imessage);
if (!busy.contains(uid))
idelete.add(imessage);
} catch (MessageRemovedException ex) {
Log.w(ex);
}
EntityLog.log(context, folder.name + " purging=" + idelete.size() + "/" + imessages.length);

Loading…
Cancel
Save