mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 09:08:49 -05:00
Don't save empty multipart body
This will correctly mark the body as missing when the message is written to the database.
This commit is contained in:
parent
74d09943c0
commit
98bdf54672
@ -141,7 +141,7 @@ public abstract class Message implements Part, CompositeBody {
|
||||
public abstract void removeHeader(String name) throws MessagingException;
|
||||
|
||||
@Override
|
||||
public abstract void setBody(Body body) throws MessagingException;
|
||||
public abstract void setBody(Body body);
|
||||
|
||||
public abstract long getId();
|
||||
|
||||
|
@ -27,7 +27,7 @@ public interface Part {
|
||||
|
||||
String getMimeType() throws MessagingException;
|
||||
|
||||
void setBody(Body body) throws MessagingException;
|
||||
void setBody(Body body);
|
||||
|
||||
void writeTo(OutputStream out) throws IOException, MessagingException;
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class MimeBodyPart extends BodyPart {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBody(Body body) throws MessagingException {
|
||||
public void setBody(Body body) {
|
||||
this.mBody = body;
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ public class MimeMessage extends Message {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBody(Body body) throws MessagingException {
|
||||
public void setBody(Body body) {
|
||||
this.mBody = body;
|
||||
}
|
||||
|
||||
@ -492,13 +492,11 @@ public class MimeMessage extends Message {
|
||||
stack.addFirst(MimeMessage.this);
|
||||
} else {
|
||||
expect(Part.class);
|
||||
try {
|
||||
MimeMessage m = new MimeMessage();
|
||||
((Part)stack.peek()).setBody(m);
|
||||
stack.addFirst(m);
|
||||
} catch (MessagingException me) {
|
||||
throw new Error(me);
|
||||
}
|
||||
Part part = (Part) stack.peek();
|
||||
|
||||
MimeMessage m = new MimeMessage();
|
||||
part.setBody(m);
|
||||
stack.addFirst(m);
|
||||
}
|
||||
}
|
||||
|
||||
@ -548,7 +546,21 @@ public class MimeMessage extends Message {
|
||||
|
||||
@Override
|
||||
public void endMultipart() {
|
||||
stack.removeFirst();
|
||||
expect(Multipart.class);
|
||||
Multipart multipart = (Multipart) stack.removeFirst();
|
||||
|
||||
boolean hasNoBodyParts = multipart.getCount() == 0;
|
||||
boolean hasNoEpilogue = multipart.getEpilogue() == null;
|
||||
if (hasNoBodyParts && hasNoEpilogue) {
|
||||
/*
|
||||
* The parser is calling startMultipart(), preamble(), and endMultipart() when all we have is
|
||||
* headers of a "multipart/*" part. But there's really no point in keeping a Multipart body if all
|
||||
* of the content is missing.
|
||||
*/
|
||||
expect(Part.class);
|
||||
Part part = (Part) stack.peek();
|
||||
part.setBody(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user