Skip to content

Commit 527f7d2

Browse files
committed
Restore previous user-agent for package manager
1 parent fc6d0a6 commit 527f7d2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

commands/instances.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
paths "github.com/arduino/go-paths-helper"
4444
"github.com/sirupsen/logrus"
4545
"google.golang.org/grpc/codes"
46+
"google.golang.org/grpc/metadata"
4647
"google.golang.org/grpc/status"
4748
)
4849

@@ -63,6 +64,11 @@ func installTool(ctx context.Context, pm *packagemanager.PackageManager, tool *c
6364

6465
// Create a new Instance ready to be initialized, supporting directories are also created.
6566
func (s *arduinoCoreServerImpl) Create(ctx context.Context, req *rpc.CreateRequest) (*rpc.CreateResponse, error) {
67+
var userAgent string
68+
if md, ok := metadata.FromIncomingContext(ctx); ok {
69+
userAgent = strings.Join(md.Get("user-agent"), " ")
70+
}
71+
6672
// Setup downloads directory
6773
downloadsDir := s.settings.DownloadsDir()
6874
if downloadsDir.NotExist() {
@@ -87,7 +93,7 @@ func (s *arduinoCoreServerImpl) Create(ctx context.Context, req *rpc.CreateReque
8793
if err != nil {
8894
return nil, err
8995
}
90-
inst, err := instances.Create(dataDir, packagesDir, userPackagesDir, downloadsDir, "", config)
96+
inst, err := instances.Create(dataDir, packagesDir, userPackagesDir, downloadsDir, userAgent, config)
9197
if err != nil {
9298
return nil, err
9399
}

0 commit comments

Comments
 (0)