-
Notifications
You must be signed in to change notification settings - Fork 806
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow pausing a resumed download even when the download hasn't alread…
…y started.
- Loading branch information
Showing
16 changed files
with
279 additions
and
140 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
.changes/next-release/bugfix-AWSS3TransferManager-6d575a5.json
This file contains 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,6 @@ | ||
{ | ||
"type": "bugfix", | ||
"category": "AWS S3 Transfer Manager", | ||
"contributor": "", | ||
"description": "Require setting the bytes transferred on transfer progress snapshots. This prevents programming bugs where the caller forgets to set the value and it gets defaulted to 0." | ||
} |
6 changes: 6 additions & 0 deletions
6
.changes/next-release/bugfix-AWSS3TransferManager-e849d27.json
This file contains 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,6 @@ | ||
{ | ||
"type": "bugfix", | ||
"category": "AWS S3 Transfer Manager", | ||
"contributor": "", | ||
"description": "Allow pausing a resumed download, even if the resumed download hasn't started." | ||
} |
This file contains 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 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 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
43 changes: 43 additions & 0 deletions
43
...ain/java/software/amazon/awssdk/transfer/s3/internal/progress/ResumeTransferProgress.java
This file contains 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,43 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package software.amazon.awssdk.transfer.s3.internal.progress; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import software.amazon.awssdk.annotations.SdkInternalApi; | ||
import software.amazon.awssdk.transfer.s3.progress.TransferProgress; | ||
import software.amazon.awssdk.transfer.s3.progress.TransferProgressSnapshot; | ||
import software.amazon.awssdk.utils.Validate; | ||
|
||
/** | ||
* An implementation of {@link TransferProgress} used when resuming a transfer. This uses a bytes-transferred of 0 until the real | ||
* progress is available (when the transfer starts). | ||
*/ | ||
@SdkInternalApi | ||
public class ResumeTransferProgress implements TransferProgress { | ||
private CompletableFuture<TransferProgress> progressFuture; | ||
|
||
public ResumeTransferProgress(CompletableFuture<TransferProgress> progressFuture) { | ||
this.progressFuture = Validate.paramNotNull(progressFuture, "progressFuture"); | ||
} | ||
|
||
@Override | ||
public TransferProgressSnapshot snapshot() { | ||
if (progressFuture.isDone() && !progressFuture.isCompletedExceptionally()) { | ||
return progressFuture.join().snapshot(); | ||
} | ||
return DefaultTransferProgressSnapshot.builder().bytesTransferred(0L).build(); | ||
} | ||
} |
This file contains 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 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.