Fixed message count

pull/184/head
M66B 5 years ago
parent d400c9b1a2
commit 43a3a655a4

@ -347,7 +347,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
db.folder().setFolderError(browsable.id, null);
int count = state.ifolder.getMessageCount();
int count = MessageHelper.getMessageCount(state.ifolder);
db.folder().setFolderTotal(browsable.id, count < 0 ? null : count);
if (criteria == null) {

@ -1015,7 +1015,7 @@ class Core {
}
ifolder.expunge();
} else {
int count = ifolder.getMessageCount();
int count = MessageHelper.getMessageCount(ifolder);
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
}
@ -1182,7 +1182,7 @@ class Core {
db.message().deleteMessage(folder.id, uid);
} finally {
int count = ifolder.getMessageCount();
int count = MessageHelper.getMessageCount(ifolder);
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
}
}
@ -1227,7 +1227,7 @@ class Core {
db.message().deleteMessage(message.id);
} finally {
int count = ifolder.getMessageCount();
int count = MessageHelper.getMessageCount(ifolder);
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
}
}
@ -1775,7 +1775,7 @@ class Core {
Log.e(ex);
throw ex;
} finally {
int count = ifolder.getMessageCount();
int count = MessageHelper.getMessageCount(ifolder);
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
// Delete local, hidden messages
@ -2379,7 +2379,7 @@ class Core {
db.message().deleteOrphans(folder.id);
}
int count = ifolder.getMessageCount();
int count = MessageHelper.getMessageCount(ifolder);
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
account.last_connected = new Date().getTime();
db.account().setAccountConnected(account.id, account.last_connected);

@ -77,6 +77,7 @@ import javax.activation.FileTypeMap;
import javax.mail.Address;
import javax.mail.BodyPart;
import javax.mail.Flags;
import javax.mail.Folder;
import javax.mail.FolderClosedException;
import javax.mail.Header;
import javax.mail.Message;
@ -2286,6 +2287,18 @@ public class MessageHelper {
}
}
static int getMessageCount(Folder folder) throws MessagingException {
// Keep alive
folder.getMessageCount();
int count = 0;
for (Message message : folder.getMessages())
if (!message.isExpunged())
count++;
return count;
}
static String sanitizeKeyword(String keyword) {
// https://tools.ietf.org/html/rfc3501
StringBuilder sb = new StringBuilder();

@ -1092,7 +1092,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
db.folder().setFolderState(folder.id, "connected");
db.folder().setFolderError(folder.id, null);
int count = ifolder.getMessageCount();
int count = MessageHelper.getMessageCount(ifolder);
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
Log.i(account.name + " folder " + folder.name + " flags=" + ifolder.getPermanentFlags());
@ -1328,7 +1328,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
db.folder().setFolderState(folder.id, "connected");
db.folder().setFolderError(folder.id, null);
int count = ifolder.getMessageCount();
int count = MessageHelper.getMessageCount(ifolder);
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
Log.i(account.name + " folder " + folder.name + " flags=" + ifolder.getPermanentFlags());

Loading…
Cancel
Save