mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 12:44:42 +00:00
Improved purge
This commit is contained in:
parent
9f22dcbb79
commit
be7a16d255
1 changed files with 8 additions and 4 deletions
|
@ -57,6 +57,7 @@ import com.sun.mail.imap.IMAPStore;
|
|||
import com.sun.mail.imap.protocol.FLAGS;
|
||||
import com.sun.mail.imap.protocol.FetchResponse;
|
||||
import com.sun.mail.imap.protocol.IMAPProtocol;
|
||||
import com.sun.mail.imap.protocol.MailboxInfo;
|
||||
import com.sun.mail.imap.protocol.MessageSet;
|
||||
import com.sun.mail.imap.protocol.UID;
|
||||
import com.sun.mail.pop3.POP3Folder;
|
||||
|
@ -1810,13 +1811,16 @@ class Core {
|
|||
private static void onPurgeFolder(Context context, JSONArray jargs, EntityFolder folder, IMAPFolder ifolder) throws MessagingException {
|
||||
// Delete all messages from folder
|
||||
try {
|
||||
final MessageSet[] sets = new MessageSet[]{new MessageSet(1, ifolder.getMessageCount())};
|
||||
|
||||
Log.i(folder.name + " purge " + MessageSet.toString(sets));
|
||||
Log.i(folder.name + " purge=" + ifolder.getMessageCount());
|
||||
ifolder.doCommand(new IMAPFolder.ProtocolCommand() {
|
||||
@Override
|
||||
public Object doCommand(IMAPProtocol protocol) throws ProtocolException {
|
||||
protocol.storeFlags(sets, new Flags(Flags.Flag.DELETED), true);
|
||||
MailboxInfo info = protocol.select(ifolder.getFullName());
|
||||
if (info.total > 0) {
|
||||
MessageSet[] sets = new MessageSet[]{new MessageSet(1, info.total)};
|
||||
EntityLog.log(context, folder.name + " purging=" + MessageSet.toString(sets));
|
||||
protocol.storeFlags(sets, new Flags(Flags.Flag.DELETED), true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue