MCPcopy
hub / github.com/wavetermdev/waveterm / DebugTermCommand

Method DebugTermCommand

pkg/wshrpc/wshserver/wshserver.go:836–864  ·  view source on GitHub ↗
(ctx context.Context, data wshrpc.CommandDebugTermData)

Source from the content-addressed store, hash-verified

834}
835
836func (ws *WshServer) DebugTermCommand(ctx context.Context, data wshrpc.CommandDebugTermData) (*wshrpc.CommandDebugTermRtnData, error) {
837 if data.BlockId == "" {
838 return nil, fmt.Errorf("blockid is required")
839 }
840 if data.Size <= 0 {
841 return nil, fmt.Errorf("size must be greater than 0")
842 }
843 waveFile, err := filestore.WFS.Stat(ctx, data.BlockId, wavebase.BlockFile_Term)
844 if err == fs.ErrNotExist {
845 return &wshrpc.CommandDebugTermRtnData{}, nil
846 }
847 if err != nil {
848 return nil, fmt.Errorf("error statting term file: %w", err)
849 }
850 readSize := data.Size
851 dataLength := waveFile.DataLength()
852 if readSize > dataLength {
853 readSize = dataLength
854 }
855 readOffset := waveFile.Size - readSize
856 readOffset, readData, err := filestore.WFS.ReadAt(ctx, data.BlockId, wavebase.BlockFile_Term, readOffset, readSize)
857 if err != nil {
858 return nil, fmt.Errorf("error reading term file: %w", err)
859 }
860 return &wshrpc.CommandDebugTermRtnData{
861 Offset: readOffset,
862 Data64: base64.StdEncoding.EncodeToString(readData),
863 }, nil
864}
865
866func (ws *WshServer) WaveInfoCommand(ctx context.Context) (*wshrpc.WaveInfoData, error) {
867 return &wshrpc.WaveInfoData{

Callers

nothing calls this directly

Calls 3

StatMethod · 0.80
DataLengthMethod · 0.80
ReadAtMethod · 0.80

Tested by

no test coverage detected