Remove local messages after upload
Only if we couldn't get the server ID to convert our local message to a
"synchronized" message.
@@ -1761,10 +1761,16 @@ public class MessagingController {
localMessage.setFlag(Flag.X_REMOTE_COPY_STARTED, true);
remoteFolder.appendMessages(Collections.singletonList(localMessage));
+ if (localMessage.getUid().startsWith(K9.LOCAL_UID_PREFIX)) {
+ // We didn't get the server UID of the uploaded message. Remove the local message now. The uploaded
+ // version will be downloaded during the next sync.
+ localFolder.destroyMessages(Collections.singletonList(localMessage));
+ } else {
localFolder.changeUid(localMessage);
for (MessagingListener l : getListeners()) {
l.messageUidChanged(account, folder, oldUid, localMessage.getUid());
}
+ }
} else {
/*
* If the remote message exists we need to determine which copy to keep.
@@ -1796,10 +1802,17 @@ public class MessagingController {
localMessage.setFlag(Flag.X_REMOTE_COPY_STARTED, true);
remoteFolder.appendMessages(Collections.singletonList(localMessage));
+ if (localMessage.getUid().startsWith(K9.LOCAL_UID_PREFIX)) {
+ // We didn't get the server UID of the uploaded message. Remove the local message now. The
+ // uploaded version will be downloaded during the next sync.
+ localFolder.destroyMessages(Collections.singletonList(localMessage));
+ } else {
localFolder.changeUid(localMessage);
for (MessagingListener l : getListeners()) {
l.messageUidChanged(account, folder, oldUid, localMessage.getUid());
}
+ }
+
if (remoteDate != null) {
remoteMessage.setFlag(Flag.DELETED, true);
if (Expunge.EXPUNGE_IMMEDIATELY == account.getExpungePolicy()) {
