Commit 240c8b3e authored by Cristian Maglie's avatar Cristian Maglie

Pass context in upload and burn-bootloader

parent 89a79cba
...@@ -188,9 +188,8 @@ func (s *arduinoCoreServerImpl) Upload(req *rpc.UploadRequest, stream rpc.Arduin ...@@ -188,9 +188,8 @@ func (s *arduinoCoreServerImpl) Upload(req *rpc.UploadRequest, stream rpc.Arduin
}) })
}) })
defer errStream.Close() defer errStream.Close()
// TODO: inject context
// ctx := stream.Context()
updatedPort, err := runProgramAction( updatedPort, err := runProgramAction(
stream.Context(),
pme, pme,
sk, sk,
req.GetImportFile(), req.GetImportFile(),
...@@ -259,7 +258,7 @@ func (s *arduinoCoreServerImpl) UploadUsingProgrammer(req *rpc.UploadUsingProgra ...@@ -259,7 +258,7 @@ func (s *arduinoCoreServerImpl) UploadUsingProgrammer(req *rpc.UploadUsingProgra
}, streamAdapter) }, streamAdapter)
} }
func runProgramAction(pme *packagemanager.Explorer, func runProgramAction(ctx context.Context, pme *packagemanager.Explorer,
sk *sketch.Sketch, sk *sketch.Sketch,
importFile, importDir, fqbnIn string, userPort *rpc.Port, importFile, importDir, fqbnIn string, userPort *rpc.Port,
programmerID string, programmerID string,
...@@ -447,7 +446,7 @@ func runProgramAction(pme *packagemanager.Explorer, ...@@ -447,7 +446,7 @@ func runProgramAction(pme *packagemanager.Explorer,
} }
// This context is kept alive for the entire duration of the upload // This context is kept alive for the entire duration of the upload
uploadCtx, uploadCompleted := context.WithCancel(context.Background()) uploadCtx, uploadCompleted := context.WithCancel(ctx)
defer uploadCompleted() defer uploadCompleted()
// Start the upload port change detector. // Start the upload port change detector.
......
...@@ -73,6 +73,7 @@ func (s *arduinoCoreServerImpl) BurnBootloader(req *rpc.BurnBootloaderRequest, s ...@@ -73,6 +73,7 @@ func (s *arduinoCoreServerImpl) BurnBootloader(req *rpc.BurnBootloaderRequest, s
defer release() defer release()
if _, err := runProgramAction( if _, err := runProgramAction(
stream.Context(),
pme, pme,
nil, // sketch nil, // sketch
"", // importFile "", // importFile
......
...@@ -17,6 +17,7 @@ package commands ...@@ -17,6 +17,7 @@ package commands
import ( import (
"bytes" "bytes"
"context"
"fmt" "fmt"
"strings" "strings"
"testing" "testing"
...@@ -186,6 +187,7 @@ func TestUploadPropertiesComposition(t *testing.T) { ...@@ -186,6 +187,7 @@ func TestUploadPropertiesComposition(t *testing.T) {
outStream := &bytes.Buffer{} outStream := &bytes.Buffer{}
errStream := &bytes.Buffer{} errStream := &bytes.Buffer{}
_, err := runProgramAction( _, err := runProgramAction(
context.Background(),
pme, pme,
nil, // sketch nil, // sketch
"", // importFile "", // importFile
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment