bazel start + mcp start
This commit is contained in:
1 parent
a90653260a
commit
4c082aca7c
33 files changed
+1728
-79
No files matched your search
@@ -468,6 +468,23 @@ func (r *Remote) DeleteHome(ctx context.Context, drive, machine string) error {
|
||||
return r.callNode(ctx, "delete_home", callParams{Drive: drive, Machine: machine}, nil)
|
||||
}
|
||||
|
||||
func (r *Remote) ReadFile(ctx context.Context, drive, machine, path string, offset int64, limit int) ([]byte, int64, error) {
|
||||
var res callParams
|
||||
err := r.callNode(ctx, "read_file", callParams{Drive: drive, Machine: machine, Path: path, Offset: offset, Max: limit}, &res)
|
||||
return res.Data, res.FileSize, tooOld(err)
|
||||
}
|
||||
|
||||
func (r *Remote) WriteFile(ctx context.Context, drive, machine, path string, offset int64, data []byte) error {
|
||||
return tooOld(r.callNode(ctx, "write_file", callParams{Drive: drive, Machine: machine, Path: path, Offset: offset, Data: data}, nil))
|
||||
}
|
||||
|
||||
func tooOld(err error) error {
|
||||
if err != nil && strings.HasPrefix(err.Error(), "unknown call ") {
|
||||
return node.ErrTooOld
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *Remote) DialAgent(ctx context.Context, machine, secret string) (node.MsgConn, error) {
|
||||
l, err := r.currentLink()
|
||||
if err != nil {
|
||||
@@ -708,6 +725,10 @@ type callParams struct {
|
||||
Max int `json:"max,omitempty"`
|
||||
Data []byte `json:"data,omitempty"`
|
||||
EOF bool `json:"eof,omitempty"`
|
||||
|
||||
Path string `json:"path,omitempty"`
|
||||
Offset int64 `json:"offset,omitempty"`
|
||||
FileSize int64 `json:"file_size,omitempty"`
|
||||
}
|
||||
|
||||
func serveCall(ctx context.Context, l *link, local node.Node, f frame) {
|
||||
@@ -751,6 +772,11 @@ func serveCall(ctx context.Context, l *link, local node.Node, f frame) {
|
||||
l.reply(f.ID, nil, local.AbortImport(ctx, p.ID))
|
||||
case "delete_home":
|
||||
l.reply(f.ID, nil, local.DeleteHome(ctx, p.Drive, p.Machine))
|
||||
case "read_file":
|
||||
data, size, err := local.ReadFile(ctx, p.Drive, p.Machine, p.Path, p.Offset, min(p.Max, transferChunk))
|
||||
l.reply(f.ID, callParams{Data: data, FileSize: size}, err)
|
||||
case "write_file":
|
||||
l.reply(f.ID, nil, local.WriteFile(ctx, p.Drive, p.Machine, p.Path, p.Offset, p.Data))
|
||||
case "open_agent":
|
||||
agent, err := local.DialAgent(ctx, p.Machine, p.Secret)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user