@@ -19,9 +19,9 @@ package daemon
1919
2020import (
2121 "context"
22- "io"
2322 "net/http"
2423
24+ "github.com/arduino/arduino-cli/arduino/utils"
2525 "github.com/arduino/arduino-cli/commands"
2626 "github.com/arduino/arduino-cli/commands/board"
2727 "github.com/arduino/arduino-cli/commands/compile"
@@ -125,8 +125,8 @@ func (s *ArduinoCoreServerImpl) Version(ctx context.Context, req *rpc.VersionReq
125125func (s * ArduinoCoreServerImpl ) Compile (req * rpc.CompileReq , stream rpc.ArduinoCore_CompileServer ) error {
126126 resp , err := compile .Compile (
127127 stream .Context (), req ,
128- feedStream (func (data []byte ) { stream .Send (& rpc.CompileResp {OutStream : data }) }),
129- feedStream (func (data []byte ) { stream .Send (& rpc.CompileResp {ErrStream : data }) }),
128+ utils . FeedStreamTo (func (data []byte ) { stream .Send (& rpc.CompileResp {OutStream : data }) }),
129+ utils . FeedStreamTo (func (data []byte ) { stream .Send (& rpc.CompileResp {ErrStream : data }) }),
130130 false ) // set debug to false
131131 if err != nil {
132132 return err
@@ -222,21 +222,6 @@ func (s *ArduinoCoreServerImpl) Upload(req *rpc.UploadReq, stream rpc.ArduinoCor
222222 return stream .Send (resp )
223223}
224224
225- func feedStream (streamer func (data []byte )) io.Writer {
226- r , w := io .Pipe ()
227- go func () {
228- data := make ([]byte , 1024 )
229- for {
230- if n , err := r .Read (data ); err == nil {
231- streamer (data [:n ])
232- } else {
233- return
234- }
235- }
236- }()
237- return w
238- }
239-
240225// LibraryDownload FIXMEDOC
241226func (s * ArduinoCoreServerImpl ) LibraryDownload (req * rpc.LibraryDownloadReq , stream rpc.ArduinoCore_LibraryDownloadServer ) error {
242227 resp , err := lib .LibraryDownload (
0 commit comments