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

fix: Fixed upload when data are coming from a dynamic source #1189

Merged
merged 6 commits into from
Aug 3, 2023

Conversation

antusus
Copy link
Contributor

@antusus antusus commented Aug 2, 2023

With OkHttp not really working with stream we have our own solution. But it can work with them as long as we tell it that content size if unknown.

This was the source of the problem in the #1183 where two threads started and one was feeding data to other. First was downloading a file second was uploading new version.
This should also address failing uploads when dealing with a stream which full size cannot be determined upfront (#1190 ).

@coveralls
Copy link

coveralls commented Aug 2, 2023

Pull Request Test Coverage Report for Build #3139

  • 27 of 35 (77.14%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 71.312%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/main/java/com/box/sdk/BinaryBodyUtils.java 3 5 60.0%
src/main/java/com/box/sdk/RequestBodyFromStream.java 21 27 77.78%
Totals Coverage Status
Change from base Build #3116: 0.03%
Covered Lines: 7149
Relevant Lines: 10025

💛 - Coveralls

}

/**
* Returns content length. If the content length cannot be derermined
Copy link
Contributor

Choose a reason for hiding this comment

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

determined

bufferedSink.write(buffer, 0, n);
totalWritten += n;
if (progressListener != null) {
progressListener.onProgressChanged(totalWritten, this.contentLength());
Copy link
Contributor

@lukaszsocha2 lukaszsocha2 Aug 3, 2023

Choose a reason for hiding this comment

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

What if contentLength() returns -1. Would progress listener work correctly ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added details here:

* In case of file uploads which are coming from a dynamic stream the file size cannot be determined and

in short total size will be -1 but bytes written should be properly returned.

Copy link
Contributor

@lukaszsocha2 lukaszsocha2 left a comment

Choose a reason for hiding this comment

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

Maybe close the issue with this pr

@antusus antusus merged commit 77b39f2 into main Aug 3, 2023
8 of 9 checks passed
@antusus antusus deleted the kb/multithreaded-upload branch August 3, 2023 14:51
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