This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 65049c37b395e3cb96bc1d4832c622f35ddb8243
Author: Benoit Tellier <[email protected]>
AuthorDate: Fri Sep 11 15:56:01 2020 +0700

    JAMES-3373 EmailBodyPart.size must reflect the body size
    
    And not the full entity size
---
 .../rfc8621/contract/EmailGetMethodContract.scala  | 38 +++++++++++-----------
 .../org/apache/james/jmap/mail/EmailBodyPart.scala |  2 +-
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailGetMethodContract.scala
 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailGetMethodContract.scala
index 63690d7..8224bf2 100644
--- 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailGetMethodContract.scala
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailGetMethodContract.scala
@@ -3190,7 +3190,7 @@ trait EmailGetMethodContract {
          |                        "bodyStructure": {
          |                            "partId": "1",
          |                            "blobId": "${messageId.serialize}_1",
-         |                            "size": 85,
+         |                            "size": 8,
          |                            "type": "text/plain",
          |                            "charset": "UTF-8"
          |                        }
@@ -3394,7 +3394,7 @@ trait EmailGetMethodContract {
          |                                    "value": "text/plain; 
charset=UTF-8"
          |                                }
          |                            ],
-         |                            "size": 85,
+         |                            "size": 8,
          |                            "type": "text/plain",
          |                            "charset": "UTF-8"
          |                        }
@@ -3499,7 +3499,7 @@ trait EmailGetMethodContract {
          |                                    "value": "$contentType"
          |                                }
          |                            ],
-         |                            "size": 2688,
+         |                            "size": 2280,
          |                            "type": "multipart/mixed",
          |                            "charset": "us-ascii",
          |                            "subParts": [
@@ -3516,7 +3516,7 @@ trait EmailGetMethodContract {
          |                                            "value": "7bit"
          |                                        }
          |                                    ],
-         |                                    "size": 97,
+         |                                    "size": 6,
          |                                    "type": "text/plain",
          |                                    "charset": "utf-8"
          |                                },
@@ -3537,7 +3537,7 @@ trait EmailGetMethodContract {
          |                                            "value": "attachment; 
filename=\\\"text1\\\""
          |                                        }
          |                                    ],
-         |                                    "size": 519,
+         |                                    "size": 271,
          |                                    "name": "text1",
          |                                    "type": "text/plain",
          |                                    "charset": "UTF-8",
@@ -3560,7 +3560,7 @@ trait EmailGetMethodContract {
          |                                            "value": "attachment; 
filename=\\\"text2\\\""
          |                                        }
          |                                    ],
-         |                                    "size": 694,
+         |                                    "size": 398,
          |                                    "name": "text2",
          |                                    "type": 
"application/vnd.ms-publisher",
          |                                    "charset": "us-ascii",
@@ -3583,7 +3583,7 @@ trait EmailGetMethodContract {
          |                                            "value": "attachment; 
filename=\\\"text3\\\""
          |                                        }
          |                                    ],
-         |                                    "size": 713,
+         |                                    "size": 412,
          |                                    "name": "text3",
          |                                    "type": "text/plain",
          |                                    "charset": "UTF-8",
@@ -3693,7 +3693,7 @@ trait EmailGetMethodContract {
          |                                    "value": "multipart/mixed; 
boundary=\\"----------=_1483455916-7086-3\\""
          |                                }
          |                            ],
-         |                            "size": 1300,
+         |                            "size": 887,
          |                            "type": "multipart/mixed",
          |                            "charset": "us-ascii",
          |                            "subParts": [
@@ -3705,7 +3705,7 @@ trait EmailGetMethodContract {
          |                                            "value": 
"multipart/alternative; boundary=\\\"------------060506070600060108040700\\\""
          |                                        }
          |                                    ],
-         |                                    "size": 483,
+         |                                    "size": 395,
          |                                    "type": "multipart/alternative",
          |                                    "charset": "us-ascii",
          |                                    "subParts": [
@@ -3722,7 +3722,7 @@ trait EmailGetMethodContract {
          |                                                    "value": "8bit"
          |                                                }
          |                                            ],
-         |                                            "size": 114,
+         |                                            "size": 18,
          |                                            "type": "text/plain",
          |                                            "charset": "ISO-8859-1"
          |                                        },
@@ -3739,7 +3739,7 @@ trait EmailGetMethodContract {
          |                                                    "value": "7bit"
          |                                                }
          |                                            ],
-         |                                            "size": 108,
+         |                                            "size": 28,
          |                                            "type": "text/html",
          |                                            "charset": "ISO-8859-1"
          |                                        }
@@ -3766,7 +3766,7 @@ trait EmailGetMethodContract {
          |                                            "value": "binary"
          |                                        }
          |                                    ],
-         |                                    "size": 249,
+         |                                    "size": 18,
          |                                    "name": "avertissement.txt",
          |                                    "type": "text/plain",
          |                                    "charset": "iso-8859-1",
@@ -3835,7 +3835,7 @@ trait EmailGetMethodContract {
          |                            {
          |                                "partId": "2",
          |                                "blobId": "${messageId.serialize}_2",
-         |                                "size": 97,
+         |                                "size": 6,
          |                                "type": "text/plain",
          |                                "charset": "utf-8"
          |                            }
@@ -3899,7 +3899,7 @@ trait EmailGetMethodContract {
          |                            {
          |                                "partId": "3",
          |                                "blobId": "${messageId.serialize}_3",
-         |                                "size": 114,
+         |                                "size": 18,
          |                                "type": "text/plain",
          |                                "charset": "ISO-8859-1"
          |                            }
@@ -3963,7 +3963,7 @@ trait EmailGetMethodContract {
          |                            {
          |                                "partId": "4",
          |                                "blobId": "${messageId.serialize}_4",
-         |                                "size": 108,
+         |                                "size": 28,
          |                                "type": "text/html",
          |                                "charset": "ISO-8859-1"
          |                            }
@@ -4630,7 +4630,7 @@ trait EmailGetMethodContract {
          |                            {
          |                                "partId": "3",
          |                                "blobId": "${messageId.serialize}_3",
-         |                                "size": 519,
+         |                                "size": 271,
          |                                "name": "text1",
          |                                "type": "text/plain",
          |                                "charset": "UTF-8",
@@ -4639,7 +4639,7 @@ trait EmailGetMethodContract {
          |                            {
          |                                "partId": "4",
          |                                "blobId": "${messageId.serialize}_4",
-         |                                "size": 694,
+         |                                "size": 398,
          |                                "name": "text2",
          |                                "type": 
"application/vnd.ms-publisher",
          |                                "charset": "us-ascii",
@@ -4648,7 +4648,7 @@ trait EmailGetMethodContract {
          |                            {
          |                                "partId": "5",
          |                                "blobId": "${messageId.serialize}_5",
-         |                                "size": 713,
+         |                                "size": 412,
          |                                "name": "text3",
          |                                "type": "text/plain",
          |                                "charset": "UTF-8",
@@ -4714,7 +4714,7 @@ trait EmailGetMethodContract {
          |                            {
          |                                "partId": "5",
          |                                "blobId": "${messageId.serialize}_5",
-         |                                "size": 249,
+         |                                "size": 18,
          |                                "name": "avertissement.txt",
          |                                "type": "text/plain",
          |                                "charset": "iso-8859-1",
diff --git 
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailBodyPart.scala
 
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailBodyPart.scala
index bb4c177..0e3d24c 100644
--- 
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailBodyPart.scala
+++ 
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailBodyPart.scala
@@ -133,7 +133,7 @@ object EmailBodyPart {
   private def size(entity: Entity): Try[Size] = {
     val countingOutputStream: CountingOutputStream = new 
CountingOutputStream(OutputStream.nullOutputStream())
     val writer = new DefaultMessageWriter
-    writer.writeEntity(entity, countingOutputStream)
+    writer.writeBody(entity.getBody, countingOutputStream)
     refineV[NonNegative](countingOutputStream.getCount) match {
       case scala.Right(size) => Success(size)
       case Left(e) => Failure(new IllegalArgumentException(e))


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to