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

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

commit b488ca80035d8311fcd6a82a3078384ff9a5c77a
Author: Benoit TELLIER <btell...@linagora.com>
AuthorDate: Fri Dec 6 22:22:24 2024 +0100

    [FIX] Run hashing on separated thread only if relevant - chatGPT suggestion
---
 .../server/blob/deduplication/DeDuplicationBlobStore.scala | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git 
a/server/blob/blob-storage-strategy/src/main/scala/org/apache/james/server/blob/deduplication/DeDuplicationBlobStore.scala
 
b/server/blob/blob-storage-strategy/src/main/scala/org/apache/james/server/blob/deduplication/DeDuplicationBlobStore.scala
index ace4cd5510..945487a8a0 100644
--- 
a/server/blob/blob-storage-strategy/src/main/scala/org/apache/james/server/blob/deduplication/DeDuplicationBlobStore.scala
+++ 
b/server/blob/blob-storage-strategy/src/main/scala/org/apache/james/server/blob/deduplication/DeDuplicationBlobStore.scala
@@ -125,9 +125,17 @@ class DeDuplicationBlobStore @Inject()(blobStoreDAO: 
BlobStoreDAO,
       .map(blobId => Tuples.of(blobId, data))
 
   private def withBlobIdFromArray: BlobIdProvider[Array[Byte]] = data => {
-    val code = Hashing.sha256.hashBytes(data)
-    val blobId = blobIdFactory.of(base64(code))
-    Mono.just(Tuples.of(blobId, data))
+    if (data.lenght < 32000) {
+      val code = Hashing.sha256.hashBytes(data)
+      val blobId = blobIdFactory.of(base64(code))
+      Mono.just(Tuples.of(blobId, data))
+    } else {
+      SMono.fromCallable(() => {
+        val code = Hashing.sha256.hashBytes(data)
+        val blobId = blobIdFactory.of(base64(code))
+        Tuples.of(blobId, data)
+      })
+    }
   }
 
   private def base64(hashCode: HashCode) = {


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to