-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[v2] add parameter to prevent overwriting existing objects in S3 high level commands #9750
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
Merged
Merged
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
751cab8
Update s3Transfer Manager
6345224
Adding no-overwrite flag for S3 upload
54e84b6
Merge pull request #9569 from rakshil14-2/no_overwrite_for_cp_command
kdaily 2493f8b
Adding No overwrite for copy operation (#9592)
rakshil14-2 64fc091
Updated s3 handler
b8d8987
Added no overwrite for download operation
17098c9
Adding new Sync strategy
eb56a58
Add no overwrite for sync operation
ab29b24
Merge pull request #9609 from rakshil14-2/no_overwrite_for_sync_opera…
kdaily 59f4f72
Add support for results that do not print newlines via new SkipFileRe…
aemous 0a8b954
Merge branch 'v2' into s3-no-overwrite-merge-v2-again
kdaily 66d24d8
Merge pull request #9908 from kdaily/s3-no-overwrite-merge-v2-again
kdaily ef03551
[v2] Perform copy with no overwrite using IfNoneMatch (#9910)
kdaily affa4d2
[v2] Add a changelog entry for S3 no overwrite feature (#9963)
kdaily 1878a7f
Update docstrings, formatting, and imports
kdaily 6cc6a7b
Merge branch 'v2' into s3-no-overwrite
kdaily File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "type": "feature", | ||
| "category": "``s3``", | ||
| "description": "Add the ``--no-overwrite`` parameter to high-level AWS S3 operations ``cp``, ``mv``, and ``sync``, which prevents overwriting objects that already exist at the destination. Implements `#2874 <https://github.com/aws/aws-cli/issues/2874>`__." | ||
| } |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"). You | ||
| # may not use this file except in compliance with the License. A copy of | ||
| # the License is located at | ||
| # | ||
| # http://aws.amazon.com/apache2.0/ | ||
| # | ||
| # or in the "license" file accompanying this file. This file is | ||
| # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
| # ANY KIND, either express or implied. See the License for the specific | ||
| # language governing permissions and limitations under the License. | ||
| import logging | ||
|
|
||
| from awscli.customizations.s3.subcommands import NO_OVERWRITE | ||
| from awscli.customizations.s3.syncstrategy.base import BaseSync | ||
|
|
||
| LOG = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class NoOverwriteSync(BaseSync): | ||
| """Sync strategy that prevents overwriting of existing files at the destination. | ||
| This strategy is used only for files that exist at both source and destination | ||
| (file_at_src_and_dest_sync_strategy). It always returns False to prevent any | ||
| overwriting of existing files, regardless of size or modification time differences. | ||
| """ | ||
|
|
||
| ARGUMENT = NO_OVERWRITE | ||
|
|
||
| def determine_should_sync(self, src_file, dest_file): | ||
| LOG.debug( | ||
| f"warning: skipping {src_file.src} -> {src_file.dest}, file exists at destination" | ||
| ) | ||
| return False |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.