-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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: Avoid extra stream copy to memory/temp if we can determine the size #38407
Conversation
Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
0277e70
to
a2b37a8
Compare
$buffer->seek(0); | ||
if ($buffer->getSize() < $this->putSizeLimit) { | ||
$streamSize = $psrStream->getSize(); | ||
if ($psrStream->isSeekable() && (int)$streamSize !== 0) { |
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 find it a bit weird to cast here and not above.
It should work though because $buffer->getSize will overwrite it later.
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.
Good stuff 👍
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.
Blocking as this has been reported to still take quite some round trips on some setup
#38763 might be the reason why this wasn't working as expected on the mentioned setup |
Man, this would really help. Where did the stream behavior change? Is there a chance that I bakcport it already for our Next (V25) release or later - as MagentaCLOUD will hopefully move fast to V27 in fall? If I understand it right the behavior change comes from #34232, which is not merged to stable 24. I assume if I backport both, this could work, right? Thanks. |
#49352 is going into a similar direction and was merged now |
On my local setup the stream was seekable and reported the proper size, so I think we can actually avoid the extra effort to copy the stream beginning to memory to determin which upload mechanism to use for cases where a size is reported. The fallback is still in place if the stream reports 0 or null as the size.
Introduced with https://github.com/nextcloud/server/pull/27877/files#diff-030e38a9e621019981acf91654c1d8d3a12ab3150dbd9fcc4c280479b8c853dbR144-R148
Test case needed adjustment since the implementation of a NonSeekableStream falsely reported to be seekable on its metadata.