1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-01 12:44:42 +00:00

Fixed downloading messages

This commit is contained in:
M66B 2018-11-05 15:07:06 +00:00
parent 913c29320f
commit ba49a8a411
3 changed files with 13 additions and 13 deletions

View file

@ -160,7 +160,7 @@ public interface DaoMessage {
@Query("SELECT id FROM message" +
" WHERE content" +
" AND preview IS NULL")
" AND (preview IS NULL OR preview = '')")
List<Long> getMessageWithoutPreview();
@Query("SELECT message.*" +
@ -225,8 +225,8 @@ public interface DaoMessage {
@Query("UPDATE message SET error = :error WHERE id = :id")
int setMessageError(long id, String error);
@Query("UPDATE message SET content = NOT preview IS NULL, preview = :preview WHERE id = :id")
int setMessageContent(long id, String preview);
@Query("UPDATE message SET content = :content, preview = :preview WHERE id = :id")
int setMessageContent(long id, boolean content, String preview);
@Query("UPDATE message SET headers = :headers WHERE id = :id")
int setMessageHeaders(long id, String headers);

View file

@ -134,12 +134,12 @@ public class FragmentOptions extends FragmentEx {
try {
Log.i(Helper.TAG, "Building preview id=" + id);
String html = message.read(context);
String text = Jsoup.parse(html).text();
String preview = text.substring(0, Math.min(text.length(), 250));
db.message().setMessageContent(message.id, preview);
String text = (html == null ? null : Jsoup.parse(html).text());
String preview = (text == null ? null : text.substring(0, Math.min(text.length(), 250)));
db.message().setMessageContent(message.id, true, preview);
} catch (IOException ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
db.message().setMessageContent(message.id, null);
db.message().setMessageContent(message.id, false, null);
if (!metered)
EntityOperation.queue(db, message, EntityOperation.BODY);
}

View file

@ -1435,10 +1435,10 @@ public class ServiceSynchronize extends LifecycleService {
MessageHelper helper = new MessageHelper((MimeMessage) imessage);
String html = helper.getHtml();
String text = (html == null ? "" : Jsoup.parse(html).text());
String preview = text.substring(0, Math.min(text.length(), PREVIEW_SIZE));
String text = (html == null ? null : Jsoup.parse(html).text());
String preview = (text == null ? null : text.substring(0, Math.min(text.length(), PREVIEW_SIZE)));
message.write(this, html);
db.message().setMessageContent(message.id, preview);
db.message().setMessageContent(message.id, true, preview);
}
private void doAttachment(EntityFolder folder, EntityOperation op, IMAPFolder ifolder, EntityMessage message, JSONArray jargs, DB db) throws JSONException, MessagingException, IOException {
@ -1896,10 +1896,10 @@ public class ServiceSynchronize extends LifecycleService {
if (!message.content)
if (!metered || (message.size != null && message.size < download)) {
String html = helper.getHtml();
String text = (html == null ? "" : Jsoup.parse(html).text());
String preview = text.substring(0, Math.min(text.length(), PREVIEW_SIZE));
String text = (html == null ? null : Jsoup.parse(html).text());
String preview = (text == null ? null : text.substring(0, Math.min(text.length(), PREVIEW_SIZE)));
message.write(context, html);
db.message().setMessageContent(message.id, preview);
db.message().setMessageContent(message.id, true, preview);
Log.i(Helper.TAG, folder.name + " downloaded message id=" + message.id + " size=" + message.size);
}