1- // Copyright 2025 , Command Line Inc.
1+ // Copyright 2026 , Command Line Inc.
22// SPDX-License-Identifier: Apache-2.0
33
44package cmd
@@ -12,10 +12,10 @@ import (
1212 "strings"
1313
1414 "github.com/wavetermdev/waveterm/pkg/remote/connparse"
15- "github.com/wavetermdev/waveterm/pkg/remote/fileshare/fsutil"
1615 "github.com/wavetermdev/waveterm/pkg/util/fileutil"
1716 "github.com/wavetermdev/waveterm/pkg/wshrpc"
1817 "github.com/wavetermdev/waveterm/pkg/wshrpc/wshclient"
18+ "github.com/wavetermdev/waveterm/pkg/wshutil"
1919)
2020
2121func convertNotFoundErr (err error ) error {
@@ -91,8 +91,38 @@ func streamWriteToFile(fileData wshrpc.FileData, reader io.Reader) error {
9191}
9292
9393func streamReadFromFile (ctx context.Context , fileData wshrpc.FileData , writer io.Writer ) error {
94- ch := wshclient .FileReadStreamCommand (RpcClient , fileData , & wshrpc.RpcOpts {Timeout : fileTimeout })
95- return fsutil .ReadFileStreamToWriter (ctx , ch , writer )
94+ broker := RpcClient .StreamBroker
95+ if broker == nil {
96+ return fmt .Errorf ("stream broker not available" )
97+ }
98+ if fileData .Info == nil {
99+ return fmt .Errorf ("file info is required" )
100+ }
101+ readerRouteId := RpcClientRouteId
102+ if readerRouteId == "" {
103+ return fmt .Errorf ("no route id available" )
104+ }
105+ conn , err := connparse .ParseURI (fileData .Info .Path )
106+ if err != nil {
107+ return fmt .Errorf ("parsing file path: %w" , err )
108+ }
109+ writerRouteId := wshutil .MakeConnectionRouteId (conn .Host )
110+ reader , streamMeta := broker .CreateStreamReader (readerRouteId , writerRouteId , 256 * 1024 )
111+ defer reader .Close ()
112+ go func () {
113+ <- ctx .Done ()
114+ reader .Close ()
115+ }()
116+ data := wshrpc.CommandFileStreamData {
117+ Info : fileData .Info ,
118+ StreamMeta : * streamMeta ,
119+ }
120+ _ , err = wshclient .FileStreamCommand (RpcClient , data , nil )
121+ if err != nil {
122+ return fmt .Errorf ("starting file stream: %w" , err )
123+ }
124+ _ , err = io .Copy (writer , reader )
125+ return err
96126}
97127
98128func fixRelativePaths (path string ) (string , error ) {
0 commit comments