-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Progress Tracker for MultipartUploader & MultipartCopy #2699
base: master
Are you sure you want to change the base?
Conversation
The strings in the return statement were over the 80 char limit
(1) Set progressThresholds[0] so that I could use array_combine on equal sized arrays (2) I redefined progressBar in setProgressThresholds after the threshold bar is created. progressBar includes the thresholds as keys and the bar as values (3) Removed the array_shift in the construct and now that logic is done by displayProgress (4) Changed assertCount to check for 9 elements instead of 8
(1) testFailedUploadPrintsPartialProgressBar - upload fails at 25% then throws exception (2) testSetProgressThresholdsThrowsException - checks non-ints (3) testDisplayProgressThrowsException - checks non-ints
- If config option is true, the total size is sent to upload state and a threshold array is created. DisplayProgress now relies on there being a threshold array, if there is no threshold array (if config = no), nothing prints. - the progress bar for multipart copy prints halfway for some reason, but the item is still copied (i'll fix this in the next commit)
progressBar and progressThresholds are no longer combined, so that array_key_first could be removed. progressThresholds[0] and array_shift are now used instead.
src/Multipart/UploadState.php
Outdated
public function getDisplayProgress($totalUploaded) | ||
{ | ||
if (!is_numeric($totalUploaded)) { | ||
throw new \InvalidArgumentException('The size of the bytes being uploaded must be a number.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do a line-wrap on this like:
throw new \InvalidArgumentException(
'The size of the bytes being uploaded must be a number.'
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one minor nit regarding line length. Otherwise LGTM!
Codecov Report
@@ Coverage Diff @@
## master #2699 +/- ##
============================================
- Coverage 92.42% 90.16% -2.26%
- Complexity 4453 4605 +152
============================================
Files 234 252 +18
Lines 11729 14167 +2438
============================================
+ Hits 10840 12774 +1934
- Misses 889 1393 +504
|
src/Multipart/UploadState.php
Outdated
public function setDisplayProgress($totalSize) | ||
{ | ||
$this->setProgressThresholds($totalSize); | ||
$this->displayProgress = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this set here? If we have made it to this function, shouldn't it already be set?
3cf2918
to
f866568
Compare
fbec615
to
66c0f96
Compare
66c0f96
to
362ae07
Compare
); | ||
} | ||
|
||
if ($this->displayProgress) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this condition should be the first one in this method by using the early return approach. For example:
public function getDisplayProgress($totalUploaded): void
{
if (!$this->displayProgress) {
return;
}
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should reject invalid input before returning early, which leaves us in a position where I don't think changing this benefits us.
362ae07
to
332e6be
Compare
Issue #, if available:
Description of changes:
'track_upload' config option added to MultipartUploader and MultipartCopy, which allows for tracking the progress of uploads in 1/8th increments.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.