Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Restore previous user-agent for package manager
  • Loading branch information
cmaglie committed Jan 22, 2025
commit 527f7d2568388bcfe6fa63b1126aa3467d3e76dd
8 changes: 7 additions & 1 deletion commands/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
paths "github.com/arduino/go-paths-helper"
"github.com/sirupsen/logrus"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)

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

// Create a new Instance ready to be initialized, supporting directories are also created.
func (s *arduinoCoreServerImpl) Create(ctx context.Context, req *rpc.CreateRequest) (*rpc.CreateResponse, error) {
var userAgent string
if md, ok := metadata.FromIncomingContext(ctx); ok {
userAgent = strings.Join(md.Get("user-agent"), " ")
}

// Setup downloads directory
downloadsDir := s.settings.DownloadsDir()
if downloadsDir.NotExist() {
Expand All @@ -87,7 +93,7 @@ func (s *arduinoCoreServerImpl) Create(ctx context.Context, req *rpc.CreateReque
if err != nil {
return nil, err
}
inst, err := instances.Create(dataDir, packagesDir, userPackagesDir, downloadsDir, "", config)
inst, err := instances.Create(dataDir, packagesDir, userPackagesDir, downloadsDir, userAgent, config)
if err != nil {
return nil, err
}
Expand Down
Loading