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


Loading…
Cancel
Save