Remove empty message check

This commit is contained in:
M66B 2019-10-05 20:44:45 +02:00
parent fd4aec91f1
commit ad4ea2bc1a
3 changed files with 35 additions and 15 deletions

View File

@ -32,6 +32,7 @@ import com.sun.mail.iap.Argument;
import com.sun.mail.iap.Response; import com.sun.mail.iap.Response;
import com.sun.mail.imap.IMAPFolder; import com.sun.mail.imap.IMAPFolder;
import com.sun.mail.imap.IMAPMessage; import com.sun.mail.imap.IMAPMessage;
import com.sun.mail.imap.IMAPStore;
import com.sun.mail.imap.protocol.IMAPProtocol; import com.sun.mail.imap.protocol.IMAPProtocol;
import com.sun.mail.imap.protocol.IMAPResponse; import com.sun.mail.imap.protocol.IMAPResponse;
@ -451,7 +452,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
if (message == null) { if (message == null) {
message = Core.synchronizeMessage(context, message = Core.synchronizeMessage(context,
account, browsable, account, browsable,
state.ifolder, (MimeMessage) isub[j], (IMAPStore) state.iservice.getStore(), state.ifolder, (MimeMessage) isub[j],
true, true, true, true,
rules, null); rules, null);
found++; found++;

View File

@ -79,6 +79,7 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
@ -320,7 +321,7 @@ class Core {
break; break;
case EntityOperation.FETCH: case EntityOperation.FETCH:
onFetch(context, jargs, folder, (IMAPFolder) ifolder, state); onFetch(context, jargs, folder, (IMAPStore) istore, (IMAPFolder) ifolder, state);
break; break;
case EntityOperation.DELETE: case EntityOperation.DELETE:
@ -348,7 +349,7 @@ class Core {
break; break;
case EntityOperation.SYNC: case EntityOperation.SYNC:
onSynchronizeMessages(context, jargs, account, folder, (IMAPFolder) ifolder, state); onSynchronizeMessages(context, jargs, account, folder, (IMAPStore) istore, (IMAPFolder) ifolder, state);
break; break;
case EntityOperation.SUBSCRIBE: case EntityOperation.SUBSCRIBE:
@ -869,7 +870,7 @@ class Core {
if (!target.synchronize || !istore.hasCapability("IDLE")) { if (!target.synchronize || !istore.hasCapability("IDLE")) {
JSONArray fargs = new JSONArray(); JSONArray fargs = new JSONArray();
fargs.put(uid); fargs.put(uid);
onFetch(context, fargs, target, itarget, state); onFetch(context, fargs, target, istore, itarget, state);
} }
} }
} catch (Throwable ex) { } catch (Throwable ex) {
@ -895,7 +896,7 @@ class Core {
} }
} }
private static void onFetch(Context context, JSONArray jargs, EntityFolder folder, IMAPFolder ifolder, State state) throws JSONException, MessagingException, IOException { private static void onFetch(Context context, JSONArray jargs, EntityFolder folder, IMAPStore istore, IMAPFolder ifolder, State state) throws JSONException, MessagingException, IOException {
long uid = jargs.getLong(0); long uid = jargs.getLong(0);
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
@ -920,7 +921,7 @@ class Core {
fp.add(IMAPFolder.FetchProfileItem.INTERNALDATE); fp.add(IMAPFolder.FetchProfileItem.INTERNALDATE);
ifolder.fetch(new Message[]{imessage}, fp); ifolder.fetch(new Message[]{imessage}, fp);
EntityMessage message = synchronizeMessage(context, account, folder, ifolder, imessage, false, download, rules, state); EntityMessage message = synchronizeMessage(context, account, folder, istore, ifolder, imessage, false, download, rules, state);
if (download && message != null) if (download && message != null)
downloadMessage(context, folder, ifolder, imessage, message.id, state); downloadMessage(context, folder, ifolder, imessage, message.id, state);
} finally { } finally {
@ -1559,7 +1560,7 @@ class Core {
private static void onSynchronizeMessages( private static void onSynchronizeMessages(
Context context, JSONArray jargs, Context context, JSONArray jargs,
EntityAccount account, final EntityFolder folder, EntityAccount account, final EntityFolder folder,
final IMAPFolder ifolder, State state) throws JSONException, MessagingException, IOException { IMAPStore istore, final IMAPFolder ifolder, State state) throws JSONException, MessagingException, IOException {
final DB db = DB.getInstance(context); final DB db = DB.getInstance(context);
try { try {
// Legacy // Legacy
@ -1843,7 +1844,7 @@ class Core {
EntityMessage message = synchronizeMessage( EntityMessage message = synchronizeMessage(
context, context,
account, folder, account, folder,
ifolder, (MimeMessage) isub[j], istore, ifolder, (MimeMessage) isub[j],
false, download, false, download,
rules, state); rules, state);
ids[from + j] = message.id; ids[from + j] = message.id;
@ -1950,14 +1951,14 @@ class Core {
static EntityMessage synchronizeMessage( static EntityMessage synchronizeMessage(
Context context, Context context,
EntityAccount account, EntityFolder folder, EntityAccount account, EntityFolder folder,
IMAPFolder ifolder, MimeMessage imessage, IMAPStore istore, IMAPFolder ifolder, MimeMessage imessage,
boolean browsed, boolean download, boolean browsed, boolean download,
List<EntityRule> rules, State state) throws MessagingException, IOException { List<EntityRule> rules, State state) throws MessagingException, IOException {
long uid = ifolder.getUID(imessage); long uid = ifolder.getUID(imessage);
try { try {
return _synchronizeMessage(context, account, folder, uid, imessage, browsed, download, rules, state); return _synchronizeMessage(context, account, folder, uid, istore, imessage, browsed, download, rules, state);
} catch (MessagingException ex) { } catch (MessagingException ex) {
// https://javaee.github.io/javamail/FAQ#imapserverbug // https://javaee.github.io/javamail/FAQ#imapserverbug
if (MessageHelper.retryRaw(ex)) try { if (MessageHelper.retryRaw(ex)) try {
@ -1980,7 +1981,7 @@ class Core {
file.delete(); file.delete();
Log.i(folder.name + " synchronizing again uid=" + uid); Log.i(folder.name + " synchronizing again uid=" + uid);
return _synchronizeMessage(context, account, folder, uid, imessage, browsed, download, rules, state); return _synchronizeMessage(context, account, folder, uid, istore, imessage, browsed, download, rules, state);
} catch (MessagingException ex1) { } catch (MessagingException ex1) {
if (MessageHelper.retryRaw(ex1)) if (MessageHelper.retryRaw(ex1))
Log.e(ex1); Log.e(ex1);
@ -1993,8 +1994,8 @@ class Core {
private static EntityMessage _synchronizeMessage( private static EntityMessage _synchronizeMessage(
Context context, Context context,
EntityAccount account, EntityFolder folder, EntityAccount account, EntityFolder folder, long uid,
long uid, MimeMessage imessage, IMAPStore istore, MimeMessage imessage,
boolean browsed, boolean download, boolean browsed, boolean download,
List<EntityRule> rules, State state) throws MessagingException, IOException { List<EntityRule> rules, State state) throws MessagingException, IOException {
@ -2141,6 +2142,24 @@ class Core {
message.warning = Helper.formatThrowable(ex, false); message.warning = Helper.formatThrowable(ex, false);
} }
if (message.total != null && message.total == 0)
try {
if (istore.hasCapability("ID")) {
Map<String, String> id = new LinkedHashMap<>();
id.put("name", context.getString(R.string.app_name));
id.put("version", BuildConfig.VERSION_NAME);
Map<String, String> sid = istore.id(id);
if (sid != null) {
StringBuilder sb = new StringBuilder();
for (String key : sid.keySet())
sb.append(" ").append(key).append("=").append(sid.get(key));
Log.e("Empty message" + sb.toString());
}
}
} catch (Throwable ex) {
Log.w(ex);
}
try { try {
db.beginTransaction(); db.beginTransaction();

View File

@ -747,8 +747,8 @@ public class MessageHelper {
Long getSize() throws MessagingException { Long getSize() throws MessagingException {
long size = imessage.getSize(); long size = imessage.getSize();
if (size == 0) //if (size == 0)
throw new MessagingException("Message empty"); // throw new MessagingException("Message empty");
return (size < 0 ? null : size); return (size < 0 ? null : size);
} }