Skip to content
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

Use Content-Range in multipart download for totalBytes #5101

Merged
merged 2 commits into from
Apr 12, 2024

Conversation

L-Applin
Copy link
Contributor

Change TransferProgressUpdater so it uses Content-Range header to determine the maximum number of bytes it tracks as part of the transfer progress listener.

Motivation and Context

For downloads, TransferProgressUpdater was expecting the totalBytes of the whole s3 object to be the value of the Content-Length header, when in fact the Content-Length header only contains the size of the current part. This cause the value of transferred bytes to exceed to the number total byte expected as soon as a 2nd part was dowloaded.

Modifications

Add a ContentRangeParser class to extract the total object size from the Content-Range header, following the MDN refgerence. Only support bytes unit.

Testing

  • Added unit tests.
  • Manual testing with s3 object.

@L-Applin L-Applin requested a review from a team as a code owner April 11, 2024 18:48
Copy link

sonarcloud bot commented Apr 11, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
73.8% Coverage on New Code (required ≥ 80%)
3.4% Duplication on New Code (required ≤ 3%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint


/**
* Parse the Content-Range to extract the total number of byte from the content. Only supports the {@code bytes} unit, any
* other unit will result in an empty OptionalLong. If the total length in unknown, which is represented by a {@code *} symbol
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, in what scenarios, total length could be unknown (*)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is part of the reference spec. I'm not sure if S3 uses it.

@L-Applin L-Applin merged commit 9f4563b into feature/master/s3mpu Apr 12, 2024
14 of 16 checks passed
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.

None yet

2 participants