Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/filestore/blockstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func TestWriteAt(t *testing.T) {
defer cancelFn()
fileName := "t3"
zoneId := uuid.NewString()
err := WFS.MakeFile(ctx, zoneId, fileName, nil, FileOptsType{})
err := WFS.MakeFile(ctx, zoneId, fileName, nil, wshrpc.FileOpts{})
if err != nil {
t.Fatalf("error creating file: %v", err)
}
Expand Down
15 changes: 9 additions & 6 deletions pkg/remote/connparse/connparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package connparse
import (
"context"
"fmt"
"regexp"
"strings"

"github.com/wavetermdev/waveterm/pkg/wshrpc"
Expand All @@ -21,6 +22,8 @@ const (
ConnHostWaveSrv = "wavesrv"
)

var windowsDriveRegex = regexp.MustCompile(`^[a-zA-Z]:`)

type Connection struct {
Scheme string
Host string
Expand Down Expand Up @@ -100,11 +103,10 @@ func ParseURI(uri string) (*Connection, error) {
if strings.HasPrefix(rest, "//") {
rest = strings.TrimPrefix(rest, "//")
split = strings.SplitN(rest, "/", 2)
host = split[0]
if len(split) > 1 {
host = split[0]
remotePath = "/" + split[1]
remotePath = split[1]
} else {
host = split[0]
remotePath = "/"
}
} else if strings.HasPrefix(rest, "/~") {
Expand All @@ -116,11 +118,10 @@ func ParseURI(uri string) (*Connection, error) {
}
} else {
split = strings.SplitN(rest, "/", 2)
host = split[0]
if len(split) > 1 {
host = split[0]
remotePath = "/" + split[1]
remotePath = split[1]
} else {
host = split[0]
remotePath = "/"
}
}
Expand All @@ -131,6 +132,8 @@ func ParseURI(uri string) (*Connection, error) {
}
if strings.HasPrefix(remotePath, "/~") {
remotePath = strings.TrimPrefix(remotePath, "/")
} else if len(remotePath) > 1 && !windowsDriveRegex.MatchString(remotePath) && !strings.HasPrefix(remotePath, "/") {
remotePath = "/" + remotePath
}
}

Expand Down
14 changes: 5 additions & 9 deletions pkg/wshrpc/wshremote/wshremote.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,25 +162,21 @@ func (impl *ServerImpl) remoteStreamFileInternal(ctx context.Context, data wshrp
if err != nil {
return err
}
path, err := wavebase.ExpandHomeDir(data.Path)
finfo, err := impl.fileInfoInternal(data.Path, true)
if err != nil {
return err
}
finfo, err := impl.fileInfoInternal(path, true)
if err != nil {
return fmt.Errorf("cannot stat file %q: %w", path, err)
return fmt.Errorf("cannot stat file %q: %w", data.Path, err)
}
dataCallback([]*wshrpc.FileInfo{finfo}, nil, byteRange)
if finfo.NotFound {
return nil
}
if finfo.Size > wshrpc.MaxFileSize {
return fmt.Errorf("file %q is too large to read, use /wave/stream-file", path)
return fmt.Errorf("file %q is too large to read, use /wave/stream-file", finfo.Path)
}
if finfo.IsDir {
return impl.remoteStreamFileDir(ctx, path, byteRange, dataCallback)
return impl.remoteStreamFileDir(ctx, finfo.Path, byteRange, dataCallback)
} else {
return impl.remoteStreamFileRegular(ctx, path, byteRange, dataCallback)
return impl.remoteStreamFileRegular(ctx, finfo.Path, byteRange, dataCallback)
}
}

Expand Down