No more orphans

This commit is contained in:
M66B 2020-11-04 11:20:54 +01:00
parent ff0e14bf60
commit d25bbcb5d9
2 changed files with 3 additions and 23 deletions

View File

@ -2482,20 +2482,9 @@ class Core {
}
}
// Add local sent messages to remote sent folder
if (EntityFolder.SENT.equals(folder.type)) {
List<EntityMessage> orphans = db.message().getOrphans(folder.id);
Log.i(folder.name + " sent orphans=" + orphans.size());
for (EntityMessage orphan : orphans) {
Log.i(folder.name + " adding orphan id=" + orphan.id);
if (orphan.content && !orphan.ui_hide)
EntityOperation.queue(context, orphan, EntityOperation.ADD);
}
} else {
// Delete not synchronized messages without uid
if (!EntityFolder.DRAFTS.equals(folder.type))
db.message().deleteOrphans(folder.id);
}
// Delete not synchronized messages without uid
if (!EntityFolder.isOutgoing(folder.type))
db.message().deleteOrphans(folder.id);
int count = MessageHelper.getMessageCount(ifolder);
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);

View File

@ -546,15 +546,6 @@ public interface DaoMessage {
" WHERE folder = :folder")
List<TupleUidl> getUidls(long folder);
@Query("SELECT * FROM message" +
" WHERE folder = :folder" +
" AND uid IS NULL" +
" AND NOT EXISTS" +
" (SELECT * FROM operation" +
" WHERE operation.message = message.id" +
" AND operation.name = '" + EntityOperation.ADD + "')")
List<EntityMessage> getOrphans(long folder);
@Query("SELECT * FROM message" +
" WHERE (:folder IS NULL OR folder = :folder)" +
" AND NOT ui_snoozed IS NULL")