func()

in lambda/internal/tarfile/s3file.go [93:120]


func (f *S3File) onCacheMiss(block *Block) (err error) {
	if f.client == nil {
		return errors.New("S3File: api client is nil, did you close the file?")
	}
	bid := block.Id
	out, err := f.client.GetObject(context.TODO(), &s3.GetObjectInput{
		Bucket: &f.s3uri.Bucket,
		Key:    &f.s3uri.Key,
		Range:  aws.String(fmt.Sprintf("bytes=%d-%d", bid*iolimits.BlockSize, (bid+1)*iolimits.BlockSize-1)),
	})
	if err != nil {
		return err
	}
	defer out.Body.Close()

	i, n := 0, 0
	for i < iolimits.BlockSize {
		n, err = out.Body.Read(block.Buf[i:iolimits.BlockSize])
		i += n
		if err != nil {
			break
		}
	}
	if err == io.EOF {
		return nil
	}
	return err
}