Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
240c8b3e
Commit
240c8b3e
authored
Apr 30, 2024
by
Cristian Maglie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass context in upload and burn-bootloader
parent
89a79cba
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
4 deletions
+6
-4
commands/service_upload.go
commands/service_upload.go
+3
-4
commands/service_upload_burnbootloader.go
commands/service_upload_burnbootloader.go
+1
-0
commands/service_upload_test.go
commands/service_upload_test.go
+2
-0
No files found.
commands/service_upload.go
View file @
240c8b3e
...
...
@@ -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
(
c
ontext
.
Background
()
)
uploadCtx
,
uploadCompleted
:=
context
.
WithCancel
(
c
tx
)
defer
uploadCompleted
()
// Start the upload port change detector.
...
...
commands/service_upload_burnbootloader.go
View file @
240c8b3e
...
...
@@ -73,6 +73,7 @@ func (s *arduinoCoreServerImpl) BurnBootloader(req *rpc.BurnBootloaderRequest, s
defer
release
()
if
_
,
err
:=
runProgramAction
(
stream
.
Context
(),
pme
,
nil
,
// sketch
""
,
// importFile
...
...
commands/service_upload_test.go
View file @
240c8b3e
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment