@@ -61,12 +61,37 @@ func ReadStream(ctx context.Context, data wshrpc.FileData) <-chan wshrpc.RespOrE
6161func readStream (conn * connparse.Connection , data wshrpc.FileData ) <- chan wshrpc.RespOrErrorUnion [wshrpc.FileData ] {
6262 byteRange := ""
6363 if data .At != nil && data .At .Size > 0 {
64- byteRange = fmt .Sprintf ("%d-%d" , data .At .Offset , data .At .Offset + int64 (data .At .Size ))
64+ byteRange = fmt .Sprintf ("%d-%d" , data .At .Offset , data .At .Offset + int64 (data .At .Size )- 1 )
6565 }
6666 streamFileData := wshrpc.CommandRemoteStreamFileData {Path : conn .Path , ByteRange : byteRange }
6767 return wshclient .RemoteStreamFileCommand (RpcClient , streamFileData , & wshrpc.RpcOpts {Route : wshutil .MakeConnectionRouteId (conn .Host )})
6868}
6969
70+ func GetConnectionRouteId (ctx context.Context , path string ) (string , error ) {
71+ conn , err := parseConnection (ctx , path )
72+ if err != nil {
73+ return "" , err
74+ }
75+ return wshutil .MakeConnectionRouteId (conn .Host ), nil
76+ }
77+
78+ func FileStream (ctx context.Context , data wshrpc.CommandFileStreamData ) (* wshrpc.FileInfo , error ) {
79+ if data .Info == nil {
80+ return nil , fmt .Errorf ("file info is required" )
81+ }
82+ log .Printf ("FileStream: %v" , data .Info .Path )
83+ conn , err := parseConnection (ctx , data .Info .Path )
84+ if err != nil {
85+ return nil , err
86+ }
87+ remoteData := wshrpc.CommandRemoteFileStreamData {
88+ Path : conn .Path ,
89+ ByteRange : data .ByteRange ,
90+ StreamMeta : data .StreamMeta ,
91+ }
92+ return wshclient .RemoteFileStreamCommand (RpcClient , remoteData , & wshrpc.RpcOpts {Route : wshutil .MakeConnectionRouteId (conn .Host )})
93+ }
94+
7095func ListEntries (ctx context.Context , path string , opts * wshrpc.FileListOpts ) ([]* wshrpc.FileInfo , error ) {
7196 log .Printf ("ListEntries: %v" , path )
7297 conn , err := parseConnection (ctx , path )
0 commit comments