Skip to content

[FIX] Limit MinIO folder depth to 2 #2710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
});
}
}
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down