CountWrapper stream_seek(0) should reset $readCount #21958
Labels
0. Needs triage
Pending check for reproducibility or if it fits our roadmap
needs info
stale
Ticket or PR with no recent activity
technical debt
Motivation
server/lib/private/Files/ObjectStore/S3ObjectTrait.php
Lines 89 to 93 in 94c74fb
Replace the MultipartUploader with ObjectUploader. The ObjectUploader uses a PutObject operation for files < 16 MB (default, can be changed) and MultipartUpload otherwise. Amazon S3 charges you for storage and requests hence less requests are better.
Blocker
It's not possible to upload files with #21952 anymore (actually uploading works but the process is aborted).
server/apps/dav/lib/Connector/Sabre/File.php
Lines 237 to 239 in 57403c7
Is thrown because the number of bytes read is not correct. If $stream->getSize() is not available (at least on my dev setup it's never available), ObjectUploader reads the first 5 MB of a stream and sets the pointer back to 0.
server/lib/private/Files/ObjectStore/ObjectStoreStorage.php
Lines 454 to 460 in 734c62b
Does not care about seek(0). The count for files uploaded via ObjectUploader is always 5 MB to high.
Uploading files via ObjectUploader works if I patch the CountWrapper like above.
Question
Is this something for https://github.com/icewind1991/streams? It depends on the use case if all bytes ever read or the bytes after the last seek(0) are wanted. It might be easier to overwrite the CountWrapper here because reset the read count on offset = 0 is a breaking change.
Also most of the storage code relies on the assumption that bytes read = bytes written to external storage. Looks like a risky change 👀
The text was updated successfully, but these errors were encountered: