-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add NewReaderWithOffset #41
Conversation
This allows opening siva files while they are being modified or opening an old index. Signed-off-by: Javi Fontan <[email protected]>
index.go
Outdated
endLastBlock, err := r.Seek(0, io.SeekEnd) | ||
if err != nil { | ||
return nil, err | ||
func readIndex(r io.ReadSeeker, o uint64) (Index, error) { |
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 it'd be worthy write a comment to know why readIndex
and readIndexAt
are different, right now it's confusing.
// NewReaderWithOffset creates a new Reader giving the position of the index. | ||
// This is useful to open siva files that are being written or reading an | ||
// old index. | ||
func NewReaderWithOffset(r io.ReadSeeker, o uint64) Reader { |
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.
what happens if the provided offset is not an index?
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.
Calling Index
function will error. The same way it errors when opening a broken siva file.
Found a problem that causes index to be read every time it is accessed. Working on a fix. |
Signed-off-by: Javi Fontan <[email protected]>
This allows opening siva files while they are being modified or opening an old index.