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
})
})
defer errStream.Close()
// TODO: inject context
// ctx := stream.Context()
updatedPort, err := runProgramAction(
stream.Context(),
pme,
sk,
req.GetImportFile(),
......@@ -259,7 +258,7 @@ func (s *arduinoCoreServerImpl) UploadUsingProgrammer(req *rpc.UploadUsingProgra
}, streamAdapter)
}
func runProgramAction(pme *packagemanager.Explorer,
func runProgramAction(ctx context.Context, pme *packagemanager.Explorer,
sk *sketch.Sketch,
importFile, importDir, fqbnIn string, userPort *rpc.Port,
programmerID string,
......@@ -447,7 +446,7 @@ func runProgramAction(pme *packagemanager.Explorer,
}
// 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()
// Start the upload port change detector.
......
......@@ -73,6 +73,7 @@ func (s *arduinoCoreServerImpl) BurnBootloader(req *rpc.BurnBootloaderRequest, s
defer release()
if _, err := runProgramAction(
stream.Context(),
pme,
nil, // sketch
"", // importFile
......
......@@ -17,6 +17,7 @@ package commands
import (
"bytes"
"context"
"fmt"
"strings"
"testing"
......@@ -186,6 +187,7 @@ func TestUploadPropertiesComposition(t *testing.T) {
outStream := &bytes.Buffer{}
errStream := &bytes.Buffer{}
_, err := runProgramAction(
context.Background(),
pme,
nil, // sketch
"", // 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