Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@ func main() {
func run(ctx *cli.Context) error {
c, err := config.Get(ctx)
if err != nil {
fmt.Fprintf(ctx.App.Writer, "%v\n\n", err)
_, _ = fmt.Fprintf(ctx.App.Writer, "%v\n\n", err)
_ = cli.ShowAppHelp(ctx)
return cli.Exit(err.Error(), 1)
}

if ctx.NArg() > 0 {
fmt.Fprintf(ctx.App.Writer,
_, _ = fmt.Fprintf(ctx.App.Writer,
"Error: bazel-remote does not take positional aguments\n")
for i := 0; i < ctx.NArg(); i++ {
fmt.Fprintf(ctx.App.Writer, "arg: %s\n", ctx.Args().Get(i))
_, _ = fmt.Fprintf(ctx.App.Writer, "arg: %s\n", ctx.Args().Get(i))
}
fmt.Fprintf(ctx.App.Writer, "\n")
_, _ = fmt.Fprintf(ctx.App.Writer, "\n")

_ = cli.ShowAppHelp(ctx)
os.Exit(1)
Expand Down
4 changes: 2 additions & 2 deletions server/grpc_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (s *grpcServer) fetchItem(ctx context.Context, uri string, headers http.Hea

if u.Scheme != "http" && u.Scheme != "https" {
s.errorLogger.Printf("unsupported URI: %s", uri)
return "", int64(-1), fmt.Errorf("Unknown URL scheme: %q", u.Scheme)
return "", int64(-1), fmt.Errorf("unknown URL scheme: %q", u.Scheme)
}

req, err := http.NewRequest(http.MethodGet, uri, nil)
Expand All @@ -223,7 +223,7 @@ func (s *grpcServer) fetchItem(ctx context.Context, uri string, headers http.Hea

s.accessLogger.Printf("GRPC ASSET FETCH %s %s", uri, resp.Status)
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return "", int64(-1), fmt.Errorf("Unsuccessful HTTP status code: %d", resp.StatusCode)
return "", int64(-1), fmt.Errorf("unsuccessful HTTP status code: %d", resp.StatusCode)
}

expectedSize := resp.ContentLength
Expand Down
18 changes: 9 additions & 9 deletions server/grpc_cas.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ func (s *grpcServer) SpliceBlob(ctx context.Context, req *pb.SpliceBlobRequest)
rc, _, err := s.cache.Get(ctx, cache.CAS, chunkDigest.Hash, chunkDigest.SizeBytes, 0)
if err != nil {
if rc != nil {
rc.Close()
_ = rc.Close()
}

return nil, grpc_status.Errorf(codes.Unknown,
Expand All @@ -474,20 +474,20 @@ func (s *grpcServer) SpliceBlob(ctx context.Context, req *pb.SpliceBlobRequest)

copiedBytes, err := io.Copy(hasher, rc)
if err != nil {
rc.Close()
_ = rc.Close()
return nil, grpc_status.Errorf(codes.Unknown,
"SpliceBlob failed to copy chunk %s/%d: %s",
chunkDigest.Hash, chunkDigest.SizeBytes, err)
}

if copiedBytes != chunkDigest.SizeBytes {
rc.Close()
_ = rc.Close()
return nil, grpc_status.Errorf(codes.Unknown,
"SpliceBlob copied unpexpected number of bytes (%d) from chunk %s/%d",
copiedBytes, chunkDigest.Hash, chunkDigest.SizeBytes)
}

rc.Close()
_ = rc.Close()
}

req.BlobDigest = &pb.Digest{
Expand Down Expand Up @@ -539,13 +539,13 @@ func (s *grpcServer) SpliceBlob(ctx context.Context, req *pb.SpliceBlobRequest)
writerResultChan := make(chan error, 1)

go func() {
defer pw.Close()
defer func() { _ = pw.Close() }()

for _, chunkDigest := range req.ChunkDigests {
rc, _, err := s.cache.Get(ctx, cache.CAS, chunkDigest.Hash, chunkDigest.SizeBytes, 0)
if err != nil {
if rc != nil {
rc.Close()
_ = rc.Close()
}
writerResultChan <- grpc_status.Errorf(codes.Unknown,
"SpliceBlob failed to get chunk %s/%d: %s",
Expand All @@ -565,22 +565,22 @@ func (s *grpcServer) SpliceBlob(ctx context.Context, req *pb.SpliceBlobRequest)

copiedBytes, err := io.Copy(pw, rc)
if err != nil {
rc.Close()
_ = rc.Close()
writerResultChan <- grpc_status.Errorf(codes.Unknown,
"SpliceBlob failed to copy chunk %s/%d: %s",
chunkDigest.Hash, chunkDigest.SizeBytes, err)
return
}

if copiedBytes != chunkDigest.SizeBytes {
rc.Close()
_ = rc.Close()
writerResultChan <- grpc_status.Errorf(codes.Unknown,
"SpliceBlob copied unpexpected number of bytes (%d) from chunk %s/%d",
copiedBytes, chunkDigest.Hash, chunkDigest.SizeBytes)
return
}

rc.Close()
_ = rc.Close()
}

writerResultChan <- nil
Expand Down