From 904d942c4cc18fabbde9acc627846aa8fed28585 Mon Sep 17 00:00:00 2001 From: Mike Sawka Date: Thu, 26 Dec 2024 10:23:28 -0800 Subject: [PATCH] fix remote file stream function (#1620) --- ROADMAP.md | 3 +-- pkg/wshrpc/wshremote/wshremote.go | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 34bdcf76b..38589b119 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -14,7 +14,7 @@ Legend: ✅ Done | 🔧 In Progress | 🔷 Planned | 🤞 Stretch Goal - 🔷 Remote S3 bucket browsing (directory + files) - 🔷 Drag & drop between preview blocks - 🔷 Drag into a preview directory from the native file browser or desktop to copy a file - - 🔷 EC-TIME timeout when transferring large files + - ✅ EC-TIME timeout when transferring large files - 🤞 log viewer - 🤞 binary viewer - 🔷 Wave Apps (Go SDK) @@ -27,7 +27,6 @@ Legend: ✅ Done | 🔧 In Progress | 🔷 Planned | 🤞 Stretch Goal - 🔷 Multi-Input between terminal blocks on the same tab - 🔧 Gemini AI support - 🔷 Monaco Theming -- 🤞 Log Viewer (stretch) - 🤞 Blockcontroller fixes for terminal escape sequences - 🤞 Explore VSCode Extension Compatibility with standalone Monaco Editor (language servers) - 🔷 Various Connection Bugs + Improvements diff --git a/pkg/wshrpc/wshremote/wshremote.go b/pkg/wshrpc/wshremote/wshremote.go index 72df33852..0692edf29 100644 --- a/pkg/wshrpc/wshremote/wshremote.go +++ b/pkg/wshrpc/wshremote/wshremote.go @@ -187,18 +187,21 @@ func (impl *ServerImpl) remoteStreamFileInternal(ctx context.Context, data wshrp func (impl *ServerImpl) RemoteStreamFileCommand(ctx context.Context, data wshrpc.CommandRemoteStreamFileData) chan wshrpc.RespOrErrorUnion[wshrpc.CommandRemoteStreamFileRtnData] { ch := make(chan wshrpc.RespOrErrorUnion[wshrpc.CommandRemoteStreamFileRtnData], 16) - defer close(ch) - err := impl.remoteStreamFileInternal(ctx, data, func(fileInfo []*wshrpc.FileInfo, data []byte) { - resp := wshrpc.CommandRemoteStreamFileRtnData{} - resp.FileInfo = fileInfo - if len(data) > 0 { - resp.Data64 = base64.StdEncoding.EncodeToString(data) + go func() { + defer close(ch) + err := impl.remoteStreamFileInternal(ctx, data, func(fileInfo []*wshrpc.FileInfo, data []byte) { + resp := wshrpc.CommandRemoteStreamFileRtnData{} + resp.FileInfo = fileInfo + if len(data) > 0 { + resp.Data64 = base64.StdEncoding.EncodeToString(data) + } + log.Printf("callback -- sending response %d\n", len(resp.Data64)) + ch <- wshrpc.RespOrErrorUnion[wshrpc.CommandRemoteStreamFileRtnData]{Response: resp} + }) + if err != nil { + ch <- respErr(err) } - ch <- wshrpc.RespOrErrorUnion[wshrpc.CommandRemoteStreamFileRtnData]{Response: resp} - }) - if err != nil { - ch <- respErr(err) - } + }() return ch }