Simplification: removed message size calculation

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

@ -710,8 +710,6 @@ class Core {
parts.isPlainOnly(),
HtmlHelper.getPreview(body),
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 {
@ -764,8 +762,6 @@ class Core {
throw new IllegalArgumentException("Attachment not found");
}
}
updateMessageSize(context, message.id);
}
static void onSynchronizeFolders(Context context, EntityAccount account, Store istore, State state) throws MessagingException {
@ -1688,36 +1684,7 @@ class Core {
} catch (Throwable 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) {

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

@ -2188,8 +2188,6 @@ public class FragmentCompose extends FragmentBase {
ics.renameTo(attachment.getFile(context));
}
Core.updateMessageSize(context, draft.id);
// Write reference text
if (ref != null && ref.content && !"list".equals(action) && !"receipt".equals(action)) {
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
HtmlHelper.getPreview(body),
null);
Core.updateMessageSize(context, draft.id);
}
} else {
String previous = Helper.readText(draft.getFile(context));
@ -2609,7 +2606,6 @@ public class FragmentCompose extends FragmentBase {
draft.plain_only,
HtmlHelper.getPreview(body),
null);
Core.updateMessageSize(context, draft.id);
}
}

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

Loading…
Cancel
Save