Auto disable partial fetch on empty message

pull/175/head
M66B 5 years ago
parent 4cdacb4698
commit eafc1197f2

@ -106,6 +106,7 @@ import javax.mail.MessageRemovedException;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.StoreClosedException;
import javax.mail.UIDFolder;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
@ -2279,7 +2280,7 @@ class Core {
}
if (message.total != null && message.total == 0)
reportEmptyMessage(context, account, istore);
reportEmptyMessage(context, state, account, istore);
try {
db.beginTransaction();
@ -2352,7 +2353,7 @@ class Core {
Long size = parts.getBodySize();
if (TextUtils.isEmpty(body) && size != null && size > 0)
reportEmptyMessage(context, account, istore);
reportEmptyMessage(context, state, account, istore);
}
}
@ -2686,7 +2687,7 @@ class Core {
Long size = parts.getBodySize();
if (TextUtils.isEmpty(body) && size != null && size > 0)
reportEmptyMessage(context, account, istore);
reportEmptyMessage(context, state, account, istore);
}
}
@ -2703,7 +2704,7 @@ class Core {
}
}
private static void reportEmptyMessage(Context context, EntityAccount account, IMAPStore istore) {
private static void reportEmptyMessage(Context context, State state, EntityAccount account, IMAPStore istore) {
try {
if (istore.hasCapability("ID")) {
Map<String, String> id = new LinkedHashMap<>();
@ -2721,6 +2722,14 @@ class Core {
} catch (Throwable ex) {
Log.w(ex);
}
// Auto disable partial fetch
if (account.partial_fetch) {
account.partial_fetch = false;
DB db = DB.getInstance(context);
db.account().setAccountPartialFetch(account.id, account.partial_fetch);
state.error(new StoreClosedException(istore));
}
}
static void notifyMessages(Context context, List<TupleMessageEx> messages, Map<Long, List<Long>> groupNotifying) {
@ -3454,7 +3463,8 @@ class Core {
// BYE, Socket is closed
recoverable = false;
if (ex instanceof FolderClosedException ||
if (ex instanceof StoreClosedException ||
ex instanceof FolderClosedException ||
ex instanceof FolderNotFoundException)
// Lost folder connection to server
recoverable = false;

@ -149,6 +149,9 @@ public interface DaoAccount {
@Query("UPDATE account SET `order` = :order WHERE id = :id")
int setAccountOrder(long id, Integer order);
@Query("UPDATE account SET partial_fetch = :partial_fetch WHERE id = :id")
int setAccountPartialFetch(long id, boolean partial_fetch);
@Query("UPDATE account SET warning = :warning WHERE id = :id")
int setAccountWarning(long id, String warning);

Loading…
Cancel
Save