func (a *internalAPIServer) GetFile(request *pfs.GetFileRequest, apiGetFileServer pfs.InternalAPI_GetFileServer) (retErr error) { defer func(start time.Time) { a.Log(request, nil, retErr, time.Since(start)) }(time.Now()) version, err := a.getVersion(apiGetFileServer.Context()) if err != nil { return err } shard, err := a.getShardForFile(request.File, version) if err != nil { return err } file, err := a.driver.GetFile(request.File, request.Shard, request.OffsetBytes, request.SizeBytes, shard) if err != nil { return err } defer func() { if err := file.Close(); err != nil && retErr == nil { retErr = err } }() return protostream.WriteToStreamingBytesServer(file, apiGetFileServer) }
func (a *internalAPIServer) GetFile(request *pfs.GetFileRequest, apiGetFileServer pfs.InternalAPI_GetFileServer) (retErr error) { version, err := a.getVersion(apiGetFileServer.Context()) if err != nil { return err } shard, err := a.getShardForFile(request.File, version) if err != nil { return err } file, err := a.driver.GetFile(request.File, shard) if err != nil { return err } defer func() { if err := file.Close(); err != nil && retErr == nil { retErr = err } }() return protostream.WriteToStreamingBytesServer( io.NewSectionReader(file, request.OffsetBytes, request.SizeBytes), apiGetFileServer, ) }