Skip to content

Commit 341b550

Browse files
committed
Perform watcher-flush higher in the call tree
1 parent 8a04112 commit 341b550

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

commands/upload/upload.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ func runProgramAction(pme *packagemanager.Explorer,
207207
outStream, errStream io.Writer,
208208
dryRun bool, userFields map[string]string) (*rpc.Port, error) {
209209

210+
defer func() {
211+
// On exit, discard all events until the watcher is closed
212+
go f.DiscardCh(watch)
213+
}()
214+
210215
if port == nil || (port.Address == "" && port.Protocol == "") {
211216
// For no-port uploads use "default" protocol
212217
port = &rpc.Port{Protocol: "default"}
@@ -521,8 +526,6 @@ func detectUploadPort(uploadPort *rpc.Port, watch <-chan *rpc.BoardListWatchResp
521526

522527
var candidate *rpc.Port
523528
defer func() {
524-
// On exit, discard all events until the watcher is closed
525-
go f.DiscardCh(watch)
526529
result.Send(candidate)
527530
}()
528531

0 commit comments

Comments
 (0)