Browse Source

Handle existing found messages

main
M66B 6 years ago
parent
commit
6789ad9c3c
1 changed files with 13 additions and 2 deletions
  1. +13
    -2
      app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java

+ 13
- 2
app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java View File

@ -28,7 +28,9 @@ import com.sun.mail.imap.IMAPMessage;
import com.sun.mail.imap.IMAPStore;
import com.sun.mail.util.FolderClosedIOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -63,6 +65,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
private IMAPStore istore = null;
private IMAPFolder ifolder = null;
private Message[] imessages = null;
private List<Long> existing = new ArrayList<>();
private int index;
private boolean searching = false;
private int loaded = 0;
@ -91,7 +94,12 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
@Override
public void run() {
Log.i(Helper.TAG, "Boundary close");
DB.getInstance(context).message().deleteFoundMessages();
DB db = DB.getInstance(context);
for (long id : existing)
db.message().setMessageFound(id, false);
db.message().deleteFoundMessages();
try {
if (istore != null)
istore.close();
@ -102,6 +110,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
istore = null;
ifolder = null;
imessages = null;
existing.clear();
}
}
});
@ -212,8 +221,10 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
ServiceSynchronize.synchronizeMessage(context, folder, ifolder, (IMAPMessage) isub[j], search != null);
count++;
loaded++;
} else
} else if (search != null) {
existing.add(message.id);
db.message().setMessageFound(message.id, true);
}
} catch (MessageRemovedException ex) {
Log.w(Helper.TAG, "Boundary " + ex + "\n" + Log.getStackTraceString(ex));
} catch (FolderClosedException ex) {


Loading…
Cancel
Save