Skip to content

Check if file exists in object store before reusing#1801

Merged
IvanBorislavovDimitrov merged 2 commits intomasterfrom
check-file-upload
Mar 27, 2026
Merged

Check if file exists in object store before reusing#1801
IvanBorislavovDimitrov merged 2 commits intomasterfrom
check-file-upload

Conversation

@IvanBorislavovDimitrov
Copy link
Copy Markdown
Contributor

LMCROSSITXSADEPLOY-3411

@@ -0,0 +1,2 @@
com.google.api.client.googleapis.services.AbstractGoogleClient.level=SEVERE
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we set this to SEVERE in test logging? Is it to reduce noise?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because now the GCP object store tests spam a lot and the build is getting too big without necessary information
this logging is only for tests

Comment on lines +84 to +85
public List<FileEntry> getExistingFileEntries(List<FileEntry> fileEntries) {
List<CompletableFuture<FileEntry>> existenceChecks = fileEntries.stream()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Azure implemenation there is validation if the fileEntries is empty. Do we need the same validation here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added it

Comment on lines +80 to +84
List<CompletableFuture<FileEntry>> existenceChecks = fileEntries.stream()
.map(fileEntry -> CompletableFuture.supplyAsync(
() -> existsInBlobStore(fileEntry),
virtualThreadExecutor))
.toList();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part if duplicated. Can it be extracted somewhere and reused here so there is less duplication?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

List<BlobId> blobIds = fileEntries.stream()
.map(fileEntry -> BlobId.of(bucketName, fileEntry.getId()))
.toList();
List<Blob> blobs = storage.get(blobIds);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this get request not executed in a thread like the other sdk-s?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it support multi fetch by multiple ids, others do not

Comment on lines +101 to +102
Storage mockedStorage = mock(Storage.class);
GcpObjectStoreFileStorage gcpFileStorage = gcpFileStorageWithMockedStorage(mockedStorage);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s some duplicated mock setup - should we pull it into a helper method?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored the class

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
78.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@IvanBorislavovDimitrov IvanBorislavovDimitrov merged commit 4f32db2 into master Mar 27, 2026
7 of 8 checks passed
@IvanBorislavovDimitrov IvanBorislavovDimitrov deleted the check-file-upload branch March 27, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants