Simplification: removed message size calculation

pull/156/head
M66B 6 years ago
parent 3a23df76a0
commit 6add12cfb9

@ -710,8 +710,6 @@ class Core {
parts.isPlainOnly(), parts.isPlainOnly(),
HtmlHelper.getPreview(body), HtmlHelper.getPreview(body),
parts.getWarnings(message.warning)); parts.getWarnings(message.warning));
updateMessageSize(context, message.id);
} }
private static void onAttachment(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, EntityOperation op, IMAPFolder ifolder) throws JSONException, MessagingException, IOException { private static void onAttachment(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, EntityOperation op, IMAPFolder ifolder) throws JSONException, MessagingException, IOException {
@ -764,8 +762,6 @@ class Core {
throw new IllegalArgumentException("Attachment not found"); throw new IllegalArgumentException("Attachment not found");
} }
} }
updateMessageSize(context, message.id);
} }
static void onSynchronizeFolders(Context context, EntityAccount account, Store istore, State state) throws MessagingException { static void onSynchronizeFolders(Context context, EntityAccount account, Store istore, State state) throws MessagingException {
@ -1688,38 +1684,9 @@ class Core {
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(ex); Log.e(ex);
} }
updateMessageSize(context, message.id);
} }
} }
static void updateMessageSize(Context context, long id) {
DB db = DB.getInstance(context);
EntityMessage message = db.message().getMessage(id);
if (message == null || !message.content)
return;
long size = message.getFile(context).length();
if (size == 0)
return;
List<EntityAttachment> attachments = db.attachment().getAttachments(message.id);
for (EntityAttachment attachment : attachments) {
if (!attachment.available)
return;
long asize = attachment.getFile(context).length();
if (asize == 0)
return;
size += asize;
}
Log.i("Setting message=" + id + " size=" + message.size + "/" + size);
db.message().setMessageSize(message.id, size);
}
static void notifyReset(Context context) { static void notifyReset(Context context) {
lastUnseen = -1; lastUnseen = -1;
Widget.update(context, -1); Widget.update(context, -1);

@ -298,8 +298,6 @@ public class EntityRule {
HtmlHelper.getPreview(body), HtmlHelper.getPreview(body),
null); null);
Core.updateMessageSize(context, reply.id);
EntityOperation.queue(context, reply, EntityOperation.SEND); EntityOperation.queue(context, reply, EntityOperation.SEND);
} }

@ -2188,8 +2188,6 @@ public class FragmentCompose extends FragmentBase {
ics.renameTo(attachment.getFile(context)); ics.renameTo(attachment.getFile(context));
} }
Core.updateMessageSize(context, draft.id);
// Write reference text // Write reference text
if (ref != null && ref.content && !"list".equals(action) && !"receipt".equals(action)) { if (ref != null && ref.content && !"list".equals(action) && !"receipt".equals(action)) {
String refBody = String.format("<p>%s %s:</p>\n<blockquote>%s</blockquote>", String refBody = String.format("<p>%s %s:</p>\n<blockquote>%s</blockquote>",
@ -2583,7 +2581,6 @@ public class FragmentCompose extends FragmentBase {
draft.plain_only, // unchanged draft.plain_only, // unchanged
HtmlHelper.getPreview(body), HtmlHelper.getPreview(body),
null); null);
Core.updateMessageSize(context, draft.id);
} }
} else { } else {
String previous = Helper.readText(draft.getFile(context)); String previous = Helper.readText(draft.getFile(context));
@ -2609,7 +2606,6 @@ public class FragmentCompose extends FragmentBase {
draft.plain_only, draft.plain_only,
HtmlHelper.getPreview(body), HtmlHelper.getPreview(body),
null); null);
Core.updateMessageSize(context, draft.id);
} }
} }

@ -203,8 +203,6 @@ public class Log {
attachOperations(context, draft.id, 5); attachOperations(context, draft.id, 5);
attachLogcat(context, draft.id, 6); attachLogcat(context, draft.id, 6);
Core.updateMessageSize(context, draft.id);
EntityOperation.queue(context, draft, EntityOperation.ADD); EntityOperation.queue(context, draft, EntityOperation.ADD);
db.setTransactionSuccessful(); db.setTransactionSuccessful();

Loading…
Cancel
Save