-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
api_dev.go
44 lines (37 loc) · 866 Bytes
/
api_dev.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package yolosvc
import (
"context"
"berty.tech/yolo/v2/go/pkg/yolopb"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (svc *service) DevDumpObjects(ctx context.Context, req *yolopb.DevDumpObjects_Request) (*yolopb.DevDumpObjects_Response, error) {
if req == nil {
req = &yolopb.DevDumpObjects_Request{}
}
if !svc.devMode {
return nil, status.Error(codes.PermissionDenied, "Permission Denied")
}
var (
batch *yolopb.Batch
err error
)
resp := yolopb.DevDumpObjects_Response{}
if req.WithPreloading {
batch, err = svc.store.GetBatchWithPreloading()
if err != nil {
return nil, err
}
} else {
batch, err = svc.store.GetBatch()
if err != nil {
return nil, err
}
}
resp.Downloads, err = svc.store.GetDumpWithPreloading()
if err != nil {
return nil, err
}
resp.Batch = batch
return &resp, nil
}