Fixing duplicate POP3 messages

This commit is contained in:
M66B 2020-05-10 11:39:11 +02:00
parent fb75830d0b
commit e05aa83e94
3 changed files with 9 additions and 1 deletions

View File

@ -1533,9 +1533,16 @@ class Core {
Log.i(folder.name + " POP existing=" + ids.size()); Log.i(folder.name + " POP existing=" + ids.size());
Map<String, TupleUidl> uidls = new HashMap<>(); Map<String, TupleUidl> uidls = new HashMap<>();
Map<String, TupleUidl> msgids = new HashMap<>();
for (TupleUidl id : ids) for (TupleUidl id : ids)
if (id.uidl != null) if (id.uidl != null)
uidls.put(id.uidl, id); uidls.put(id.uidl, id);
else if (id.msgid != null)
msgids.put(id.msgid, id);
for (TupleUidl id : uidls.values())
if (id.msgid != null && msgids.containsKey(id.msgid))
db.message().deleteMessage(id.id);
for (Message imessage : imessages) for (Message imessage : imessages)
try { try {

View File

@ -485,7 +485,7 @@ public interface DaoMessage {
" AND NOT uid IS NULL") " AND NOT uid IS NULL")
List<Long> getUids(long folder, Long received); List<Long> getUids(long folder, Long received);
@Query("SELECT uidl, msgid FROM message" + @Query("SELECT id, uidl, msgid FROM message" +
" WHERE folder = :folder") " WHERE folder = :folder")
List<TupleUidl> getUidls(long folder); List<TupleUidl> getUidls(long folder);

View File

@ -20,6 +20,7 @@ package eu.faircode.email;
*/ */
public class TupleUidl { public class TupleUidl {
long id;
String uidl; String uidl;
String msgid; String msgid;
} }