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

Proposal: Download.Read() should always return some bytes until EOF #99

Open
Erikvv opened this issue May 15, 2022 · 4 comments
Open

Proposal: Download.Read() should always return some bytes until EOF #99

Erikvv opened this issue May 15, 2022 · 4 comments

Comments

@Erikvv
Copy link
Contributor

Erikvv commented May 15, 2022

The user usually calls Download.Read(p []byte) (n int, err error) in a loop. Currently at the boundary between two segments one call returns 0 bytes.

This causes bugs and additional complexity for library authors and users. Example:

storj-thirdparty/nextcloud-app#4 / storj-thirdparty/uplink-php#12
storj/uplink-java#10

I propose we change the behavior so that Download.Read() never returns 0 bytes, unless there are no more bytes left to download.

I'm not sure where this behaviour actually emerges and should be changed. Maybe somewhere in storj.io/common/ranger.concatReader or storj.io/common/readcloser.multiReadCloser.

@egonelbre
Copy link
Member

An easy fix would be to retry in the top-level download implementation.

@egonelbre
Copy link
Member

Oh, also, it could also be a side-effect of avoiding to return error and read 0 bytes from some internal read. (I'm not sure, but I think we had that property in https://github.com/storj/uplink/blob/main/private/piecestore/download.go#L114)

@ifraixedes
Copy link
Member

@Erikvv does the uplink-c library return an error (specifically EOF) when the 0 bytes are returned at the boundary between 2 segments?

@Erikvv
Copy link
Contributor Author

Erikvv commented Aug 22, 2022

@ifraixedes No there's no error, EOF is only at the end of the object (or requested range).

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

No branches or pull requests

3 participants