39 lines
621 B
Go
39 lines
621 B
Go
package blob
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
type SeekBlobArgs struct {
|
|
ReaderID ReaderID
|
|
Offset int64
|
|
Whence int
|
|
}
|
|
|
|
type SeekBlobReply struct {
|
|
Read int64
|
|
EOF bool
|
|
}
|
|
|
|
func (s *Service) SeekBlob(ctx context.Context, args *SeekBlobArgs, reply *SeekBlobReply) error {
|
|
reader, err := s.getOpenedReader(args.ReaderID)
|
|
if err != nil {
|
|
return errors.WithStack(err)
|
|
}
|
|
|
|
read, err := reader.Seek(args.Offset, args.Whence)
|
|
if err != nil && !errors.Is(err, io.EOF) {
|
|
return errors.WithStack(err)
|
|
}
|
|
|
|
*reply = SeekBlobReply{
|
|
Read: read,
|
|
EOF: errors.Is(err, io.EOF),
|
|
}
|
|
|
|
return nil
|
|
}
|