Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e3d18e7 authored by Vincent Breitmoser's avatar Vincent Breitmoser
Browse files

we don't use displayName from database either (for now), fix tests to reflect that

parent 7cb6fa10
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -9,16 +9,14 @@ public class LocalBodyPart extends MimeBodyPart implements LocalPart {
    private final String accountUuid;
    private final LocalMessage message;
    private final long messagePartId;
    private final String displayName;
    private final long size;

    public LocalBodyPart(String accountUuid, LocalMessage message, long messagePartId, String displayName, long size)
    public LocalBodyPart(String accountUuid, LocalMessage message, long messagePartId, long size)
            throws MessagingException {
        super();
        this.accountUuid = accountUuid;
        this.message = message;
        this.messagePartId = messagePartId;
        this.displayName = displayName;
        this.size = size;
    }

@@ -32,11 +30,6 @@ public class LocalBodyPart extends MimeBodyPart implements LocalPart {
        return messagePartId;
    }

    @Override
    public String getDisplayName() {
        return displayName;
    }

    @Override
    public long getSize() {
        return size;
+4 −3
Original line number Diff line number Diff line
@@ -712,11 +712,12 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
        long parentId = cursor.getLong(2);
        String mimeType = cursor.getString(3);
        long size = cursor.getLong(4);
        String displayName = cursor.getString(5);
        byte[] header = cursor.getBlob(6);
        int dataLocation = cursor.getInt(9);
        String serverExtra = cursor.getString(15);
        // TODO we don't currently cache the part types. might want to do that at a later point?
        // TODO we don't currently cache much of the part data which is computed with AttachmentInfoExtractor,
        // TODO might want to do that at a later point?
        // String displayName = cursor.getString(5);
        // int type = cursor.getInt(1);
        // boolean firstClassAttachment = (type != MessagePartType.HIDDEN_ATTACHMENT);

@@ -731,7 +732,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {

            String parentMimeType = parentPart.getMimeType();
            if (MimeUtility.isMultipart(parentMimeType)) {
                BodyPart bodyPart = new LocalBodyPart(getAccountUuid(), message, id, displayName, size);
                BodyPart bodyPart = new LocalBodyPart(getAccountUuid(), message, id, size);
                ((Multipart) parentPart.getBody()).addBodyPart(bodyPart);
                part = bodyPart;
            } else if (MimeUtility.isMessage(parentMimeType)) {
+0 −1
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@ package com.fsck.k9.mailstore;
public interface LocalPart {
    String getAccountUuid();
    long getId();
    String getDisplayName();
    long getSize();
    LocalMessage getMessage();
}
+0 −1
Original line number Diff line number Diff line
@@ -248,7 +248,6 @@ public class MigrationTest {
        LocalBodyPart attachmentPart = (LocalBodyPart) body.getBodyPart(1);
        Assert.assertEquals("image/png", attachmentPart.getMimeType());
        Assert.assertEquals("2", attachmentPart.getServerExtra());
        Assert.assertEquals("k9small.png", attachmentPart.getDisplayName());
        Assert.assertEquals("attachment", MimeUtility.getHeaderParameter(attachmentPart.getDisposition(), null));
        Assert.assertEquals("k9small.png", MimeUtility.getHeaderParameter(attachmentPart.getDisposition(), "filename"));
        Assert.assertEquals("2250", MimeUtility.getHeaderParameter(attachmentPart.getDisposition(), "size"));
+0 −4
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ public class AttachmentInfoExtractorTest {
    public static final long TEST_SIZE = 123L;
    public static final String TEST_ACCOUNT_UUID = "uuid";
    public static final long TEST_ID = 234L;
    public static final String TEST_DISPLAY_NAME = "test-display-name";
    public static final String[] TEST_CONTENT_ID = new String[] { "test-content-id" };


@@ -57,14 +56,11 @@ public class AttachmentInfoExtractorTest {
        when(part.getMimeType()).thenReturn(TEST_MIME_TYPE);
        when(part.getSize()).thenReturn(TEST_SIZE);
        when(part.getAccountUuid()).thenReturn(TEST_ACCOUNT_UUID);
        when(part.getDisplayName()).thenReturn(TEST_DISPLAY_NAME);

        AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfo(part);

        assertEquals(AttachmentProvider.getAttachmentUri(TEST_ACCOUNT_UUID, TEST_ID), attachmentViewInfo.uri);
        assertEquals(true, attachmentViewInfo.firstClassAttachment);
        assertEquals(TEST_SIZE, attachmentViewInfo.size);
        assertEquals(TEST_DISPLAY_NAME, attachmentViewInfo.displayName);
        assertEquals(TEST_MIME_TYPE, attachmentViewInfo.mimeType);
    }