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.imap.IMAPFolder;
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.IMAPResponse;
@ -451,7 +452,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
if (message == null) {
message = Core.synchronizeMessage(context,
account, browsable,
state.ifolder, (MimeMessage) isub[j],
(IMAPStore) state.iservice.getStore(), state.ifolder, (MimeMessage) isub[j],
true, true,
rules, null);
found++;

View File

@ -79,6 +79,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -320,7 +321,7 @@ class Core {
break;
case EntityOperation.FETCH:
onFetch(context, jargs, folder, (IMAPFolder) ifolder, state);
onFetch(context, jargs, folder, (IMAPStore) istore, (IMAPFolder) ifolder, state);
break;
case EntityOperation.DELETE:
@ -348,7 +349,7 @@ class Core {
break;
case EntityOperation.SYNC:
onSynchronizeMessages(context, jargs, account, folder, (IMAPFolder) ifolder, state);
onSynchronizeMessages(context, jargs, account, folder, (IMAPStore) istore, (IMAPFolder) ifolder, state);
break;
case EntityOperation.SUBSCRIBE:
@ -869,7 +870,7 @@ class Core {
if (!target.synchronize || !istore.hasCapability("IDLE")) {
JSONArray fargs = new JSONArray();
fargs.put(uid);
onFetch(context, fargs, target, itarget, state);
onFetch(context, fargs, target, istore, itarget, state);
}
}
} 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);
DB db = DB.getInstance(context);
@ -920,7 +921,7 @@ class Core {
fp.add(IMAPFolder.FetchProfileItem.INTERNALDATE);
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)
downloadMessage(context, folder, ifolder, imessage, message.id, state);
} finally {
@ -1559,7 +1560,7 @@ class Core {
private static void onSynchronizeMessages(
Context context, JSONArray jargs,
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);
try {
// Legacy
@ -1843,7 +1844,7 @@ class Core {
EntityMessage message = synchronizeMessage(
context,
account, folder,
ifolder, (MimeMessage) isub[j],
istore, ifolder, (MimeMessage) isub[j],
false, download,
rules, state);
ids[from + j] = message.id;
@ -1950,14 +1951,14 @@ class Core {
static EntityMessage synchronizeMessage(
Context context,
EntityAccount account, EntityFolder folder,
IMAPFolder ifolder, MimeMessage imessage,
IMAPStore istore, IMAPFolder ifolder, MimeMessage imessage,
boolean browsed, boolean download,
List<EntityRule> rules, State state) throws MessagingException, IOException {
long uid = ifolder.getUID(imessage);
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) {
// https://javaee.github.io/javamail/FAQ#imapserverbug
if (MessageHelper.retryRaw(ex)) try {
@ -1980,7 +1981,7 @@ class Core {
file.delete();
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) {
if (MessageHelper.retryRaw(ex1))
Log.e(ex1);
@ -1993,8 +1994,8 @@ class Core {
private static EntityMessage _synchronizeMessage(
Context context,
EntityAccount account, EntityFolder folder,
long uid, MimeMessage imessage,
EntityAccount account, EntityFolder folder, long uid,
IMAPStore istore, MimeMessage imessage,
boolean browsed, boolean download,
List<EntityRule> rules, State state) throws MessagingException, IOException {
@ -2141,6 +2142,24 @@ class Core {
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 {
db.beginTransaction();

View File

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