Fix S3DBService and LocalDBService file overwrite handling during downloads#5911
Merged
dlvenable merged 4 commits intoopensearch-project:mainfrom Jul 31, 2025
Merged
Fix S3DBService and LocalDBService file overwrite handling during downloads#5911dlvenable merged 4 commits intoopensearch-project:mainfrom
dlvenable merged 4 commits intoopensearch-project:mainfrom
Conversation
dlvenable
requested changes
Jul 29, 2025
Member
dlvenable
left a comment
There was a problem hiding this comment.
Thanks! This looks good, though I have one small comment.
| S3DBService s3DBService = createObjectUnderTest(); | ||
| s3DBService.initiateDownload(); | ||
|
|
||
| String finalContent = Files.readString(destinationFile.toPath()); |
Member
There was a problem hiding this comment.
Please move these three lines out of the try block. They don't require the mocked static.
Member
|
Also, your DCO check is failing. You have the use the same email for sign-off as you use in the commits. See: https://github.com/opensearch-project/data-prepper/pull/5911/checks?check_run_id=46964106373 |
added 3 commits
July 29, 2025 16:11
Signed-off-by: kirtanhk <kirtanhk@amazon.com>
Signed-off-by: kirtanhk <kirtanhk@amazon.com>
Signed-off-by: kirtanhk <kirtanhk@amazon.com>
Signed-off-by: kirtanhk <kirtanhk@amazon.com>
dlvenable
approved these changes
Jul 31, 2025
san81
approved these changes
Jul 31, 2025
dlvenable
pushed a commit
that referenced
this pull request
Jul 31, 2025
…nloads (#5911) (#5934) Fix S3DBService/LocalDBService file overwrite handling during downloads (cherry picked from commit b87890a) Signed-off-by: kirtanhk <kirtanhk@amazon.com> Co-authored-by: Kirtan Kakadiya <35823164+KirtanKakadiya@users.noreply.github.com> Co-authored-by: kirtanhk <kirtanhk@amazon.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
S3DBService
When downloading the databases from S3, the download will fail if the current file exists as it is not able to overwrite the file. The method which causes this issue is S3DBService.buildRequestAndDownloadFile. Currently this method uses Files.copy from the java.nio.file.Files package which does not allow overwrites.
The solution would be to use the ResponseTransformer.toFile(path) method like this:
S3Client.getObject((b) -> { b.bucket(bucketName).key(key);}, ResponseTransformer.toFile(destination));LocalDBService
When downloading the databases locally, the download will fail if the current file exists as it is not able to overwrite the file. The method which causes this issue is LocalDBService.initiateDownload. Currently this method uses Files.copy from the java.nio.file.Files package which does not allow overwrites.
The solution would be to use enable the overwrite option using the StandardCopyOption.REPLACE_EXISTING like this:
Files.copy(sourceFile.toPath(), destinationFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
Issues Resolved
Resolves #5898 , #5899
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.