diff --git a/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/S3WithMinIOGenerationAwareBlobIdTest.java b/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/S3WithMinIOGenerationAwareBlobIdTest.java index 6c61eec5f0c..a13a9e772c7 100644 --- a/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/S3WithMinIOGenerationAwareBlobIdTest.java +++ b/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/S3WithMinIOGenerationAwareBlobIdTest.java @@ -126,7 +126,7 @@ void saveShouldReturnBlobIdOfString(BlobStore.StoragePolicy storagePolicy) { String blobIdString = blobId.asString(); // Then: BlobId string and parsed BlobId should match expectations - assertThat(blobIdString).isEqualTo("1/628/M/f/e/m/XjFVhqwZi9eYtmKc5JA9CJlHbVdBqfMuLlIbamY="); + assertThat(blobIdString).isEqualTo("1/628/M/f/emXjFVhqwZi9eYtmKc5JA9CJlHbVdBqfMuLlIbamY="); assertThat(blobId).isEqualTo(blobIdFactory().parse(blobIdString)); } diff --git a/server/blob/blob-storage-strategy/src/main/java/org/apache/james/server/blob/deduplication/MinIOGenerationAwareBlobId.java b/server/blob/blob-storage-strategy/src/main/java/org/apache/james/server/blob/deduplication/MinIOGenerationAwareBlobId.java index ac0fd4b8cb5..c612e17e532 100644 --- a/server/blob/blob-storage-strategy/src/main/java/org/apache/james/server/blob/deduplication/MinIOGenerationAwareBlobId.java +++ b/server/blob/blob-storage-strategy/src/main/java/org/apache/james/server/blob/deduplication/MinIOGenerationAwareBlobId.java @@ -74,13 +74,11 @@ public BlobId parse(String id) { } private static String injectFoldersInBlobId(String blobIdPart) { - int folderDepthToCreate = 4; + int folderDepthToCreate = 2; if (blobIdPart.length() > folderDepthToCreate) { return blobIdPart.charAt(0) + "/" + blobIdPart.charAt(1) + "/" + - blobIdPart.charAt(2) + "/" + - blobIdPart.charAt(3) + "/" + - blobIdPart.substring(4); + blobIdPart.substring(2); } return blobIdPart; } diff --git a/server/blob/blob-storage-strategy/src/test/java/org/apache/james/server/blob/deduplication/MinIOGenerationAwareBlobIdTest.java b/server/blob/blob-storage-strategy/src/test/java/org/apache/james/server/blob/deduplication/MinIOGenerationAwareBlobIdTest.java index 8dd11b91827..370c6d29b4e 100644 --- a/server/blob/blob-storage-strategy/src/test/java/org/apache/james/server/blob/deduplication/MinIOGenerationAwareBlobIdTest.java +++ b/server/blob/blob-storage-strategy/src/test/java/org/apache/james/server/blob/deduplication/MinIOGenerationAwareBlobIdTest.java @@ -62,7 +62,7 @@ void ofShouldGenerateABlobIdOfTheRightGeneration() { SoftAssertions.assertSoftly(soft -> { soft.assertThat(actual.getFamily()).isEqualTo(GenerationAwareBlobId.Configuration.DEFAULT.getFamily()); soft.assertThat(actual.getGeneration()).isEqualTo(628L); - soft.assertThat(actual.getDelegate()).isEqualTo(delegate.of("4/c/c/b/692e-3efb-40e9-8876-4ecfd51ffd4d")); + soft.assertThat(actual.getDelegate()).isEqualTo(delegate.of("4/c/cb692e-3efb-40e9-8876-4ecfd51ffd4d")); }); } } @@ -94,6 +94,22 @@ void previousBlobIdsShouldBeParsable() { }); } + @Test + void previousFourFolderDepthBlobIdsShouldBeParsedAsMinIOGenerationAwareBlobId() { + String fourDepthBlobIdString = delegate.of("1/628/3/6/8/2/5033-d835-4490-9f5a-eef120b1e85c").asString(); + + BlobId actual = testee.parse(fourDepthBlobIdString); + assertThat(actual) + .isInstanceOfSatisfying(MinIOGenerationAwareBlobId.class, actualBlobId -> { + SoftAssertions.assertSoftly(soft -> { + soft.assertThat(actualBlobId.getFamily()).isEqualTo(1); + soft.assertThat(actualBlobId.getGeneration()).isEqualTo(628L); + soft.assertThat(actualBlobId.getDelegate().asString()).isEqualTo("3/6/8/2/5033-d835-4490-9f5a-eef120b1e85c"); + soft.assertThat(actualBlobId.asString()).isEqualTo("1/628/3/6/8/2/5033-d835-4490-9f5a-eef120b1e85c"); + }); + }); + } + @Test void noFamilyShouldBeParsable() { String originalBlobId = "abcdef"; @@ -206,7 +222,7 @@ void shouldMatchPojoContract() { void asStringShouldIntegrateFamilyAndGeneration() { BlobId blobId = testee.of("36825033-d835-4490-9f5a-eef120b1e85c"); - assertThat(blobId.asString()).isEqualTo("1/628/3/6/8/2/5033-d835-4490-9f5a-eef120b1e85c"); + assertThat(blobId.asString()).isEqualTo("1/628/3/6/825033-d835-4490-9f5a-eef120b1e85c"); } @Test @@ -220,7 +236,8 @@ void asStringShouldReturnDelegateForZeroFamily() { @ValueSource(strings = { "1/2/a/b/c/d/efgh", "abc", - "1/2/abc" + "1/2/abc", + "1/628/3/6/8/2/5033-d835-4490-9f5a-eef120b1e85c" }) void asStringShouldRevertFromString(String blobIdString) { BlobId blobId = testee.parse(blobIdString);