mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-11-28 13:10:24 +08:00
Adds the S3 `fileshare` implementation This also updates `wsh file cp` so it behaves more like `cp` for things like copying directories and directory entries. It's not meant to align with `cp` on everything, though. Our `wsh cp` will be recursive and will create intermediate directories by default. This also adds new aliases for `wsh view`: `wsh preview` and `wsh open` --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: sawka <mike@commandline.dev> Co-authored-by: Sylvia Crowe <software@oneirocosm.com>
37 lines
963 B
Go
37 lines
963 B
Go
package wavefileutil
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/wavetermdev/waveterm/pkg/filestore"
|
|
"github.com/wavetermdev/waveterm/pkg/remote/fileshare/fsutil"
|
|
"github.com/wavetermdev/waveterm/pkg/util/fileutil"
|
|
"github.com/wavetermdev/waveterm/pkg/wshrpc"
|
|
)
|
|
|
|
const (
|
|
WaveFilePathPattern = "wavefile://%s/%s"
|
|
)
|
|
|
|
func WaveFileToFileInfo(wf *filestore.WaveFile) *wshrpc.FileInfo {
|
|
path := fmt.Sprintf(WaveFilePathPattern, wf.ZoneId, wf.Name)
|
|
rtn := &wshrpc.FileInfo{
|
|
Path: path,
|
|
Dir: fsutil.GetParentPathString(path),
|
|
Name: wf.Name,
|
|
Opts: &wf.Opts,
|
|
Size: wf.Size,
|
|
Meta: &wf.Meta,
|
|
SupportsMkdir: false,
|
|
}
|
|
fileutil.AddMimeTypeToFileInfo(path, rtn)
|
|
return rtn
|
|
}
|
|
|
|
func WaveFileListToFileInfoList(wfList []*filestore.WaveFile) []*wshrpc.FileInfo {
|
|
var fileInfoList []*wshrpc.FileInfo
|
|
for _, wf := range wfList {
|
|
fileInfoList = append(fileInfoList, WaveFileToFileInfo(wf))
|
|
}
|
|
return fileInfoList
|
|
}
|