Skip to content

Commit 93b7269

Browse files
authored
Do not allow large/recursive file transfers (for now), remove s3 and wavefile fs implementations (#2808)
Big simplification. Remove the FileShare interface that abstracted wsh://, s3://, and wavefile:// files. It produced a lot of complexity for very little usage. We're just going to focus on the wsh:// implementation since that's core to our remote workflows. * remove s3 implementation (and connections, and picker items for preview) * remove capabilities for FE * remove wavefile backend impl as well * simplify wsh file remote backend * remove ability to copy/move/ls recursively * limit file transfers to 32m the longer term fix here is to use the new streaming RPC primitives. they have full end-to-end flow-control built in and will not create pipeline stalls, blocking other requests, and OOM issues. these other impls had to be removed (or fixed) because transferring large files could cause stalls or crashes with the new router infrastructure.
1 parent 01a26d5 commit 93b7269

46 files changed

Lines changed: 775 additions & 3747 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/generatego/main-generatego.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ func GenerateWshClient() error {
3131
"github.com/wavetermdev/waveterm/pkg/waveobj",
3232
"github.com/wavetermdev/waveterm/pkg/wps",
3333
"github.com/wavetermdev/waveterm/pkg/vdom",
34-
"github.com/wavetermdev/waveterm/pkg/util/iochan/iochantypes",
3534
"github.com/wavetermdev/waveterm/pkg/aiusechat/uctypes",
3635
})
3736
wshDeclMap := wshrpc.GenerateWshCommandDeclMap()

cmd/wsh/cmd/wshcmd-file-util.go

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/wavetermdev/waveterm/pkg/remote/connparse"
1515
"github.com/wavetermdev/waveterm/pkg/remote/fileshare/fsutil"
1616
"github.com/wavetermdev/waveterm/pkg/util/fileutil"
17-
"github.com/wavetermdev/waveterm/pkg/util/wavefileutil"
1817
"github.com/wavetermdev/waveterm/pkg/wshrpc"
1918
"github.com/wavetermdev/waveterm/pkg/wshrpc/wshclient"
2019
)
@@ -96,90 +95,6 @@ func streamReadFromFile(ctx context.Context, fileData wshrpc.FileData, writer io
9695
return fsutil.ReadFileStreamToWriter(ctx, ch, writer)
9796
}
9897

99-
type fileListResult struct {
100-
info *wshrpc.FileInfo
101-
err error
102-
}
103-
104-
func streamFileList(zoneId string, path string, recursive bool, filesOnly bool) (<-chan fileListResult, error) {
105-
resultChan := make(chan fileListResult)
106-
107-
// If path doesn't end in /, do a single file lookup
108-
if path != "" && !strings.HasSuffix(path, "/") {
109-
go func() {
110-
defer close(resultChan)
111-
112-
fileData := wshrpc.FileData{
113-
Info: &wshrpc.FileInfo{
114-
Path: fmt.Sprintf(wavefileutil.WaveFilePathPattern, zoneId, path)},
115-
}
116-
117-
info, err := wshclient.FileInfoCommand(RpcClient, fileData, &wshrpc.RpcOpts{Timeout: 2000})
118-
err = convertNotFoundErr(err)
119-
if err == fs.ErrNotExist {
120-
resultChan <- fileListResult{err: fmt.Errorf("%s: No such file or directory", path)}
121-
return
122-
}
123-
if err != nil {
124-
resultChan <- fileListResult{err: err}
125-
return
126-
}
127-
resultChan <- fileListResult{info: info}
128-
}()
129-
return resultChan, nil
130-
}
131-
132-
// Directory listing case
133-
go func() {
134-
defer close(resultChan)
135-
136-
prefix := path
137-
prefixLen := len(prefix)
138-
offset := 0
139-
foundAny := false
140-
141-
for {
142-
listData := wshrpc.FileListData{
143-
Path: fmt.Sprintf(wavefileutil.WaveFilePathPattern, zoneId, prefix),
144-
Opts: &wshrpc.FileListOpts{
145-
All: recursive,
146-
Offset: offset,
147-
Limit: 100}}
148-
149-
files, err := wshclient.FileListCommand(RpcClient, listData, &wshrpc.RpcOpts{Timeout: 2000})
150-
if err != nil {
151-
resultChan <- fileListResult{err: err}
152-
return
153-
}
154-
155-
if len(files) == 0 {
156-
if !foundAny && prefix != "" {
157-
resultChan <- fileListResult{err: fmt.Errorf("%s: No such file or directory", path)}
158-
}
159-
return
160-
}
161-
162-
for _, f := range files {
163-
if filesOnly && f.IsDir {
164-
continue
165-
}
166-
foundAny = true
167-
if prefixLen > 0 {
168-
f.Name = f.Name[prefixLen:]
169-
}
170-
resultChan <- fileListResult{info: f}
171-
}
172-
173-
if len(files) < 100 {
174-
return
175-
}
176-
offset += len(files)
177-
}
178-
}()
179-
180-
return resultChan, nil
181-
}
182-
18398
func fixRelativePaths(path string) (string, error) {
18499
conn, err := connparse.ParseURI(path)
185100
if err != nil {

0 commit comments

Comments
 (0)