add cp command
This commit is contained in:
@@ -25,3 +25,21 @@ func (s *Server) FileRead(ctx context.Context, file *portal.FileReadRequest) (*p
|
||||
|
||||
return &portal.FileReadResponse{State: portal.State_UNKNOWN, Content: string(content)}, nil
|
||||
}
|
||||
|
||||
func (s *Server) FileCp(ctx context.Context, file *portal.FileCpRequest) (*portal.FileCpResponse, error) {
|
||||
fields := log.Fields{
|
||||
"context": "file",
|
||||
"command": "cp",
|
||||
"name": file.GetPath(),
|
||||
}
|
||||
log := log.WithFields(fields)
|
||||
log.Debug("Received file cp request")
|
||||
|
||||
err := os.WriteFile(file.GetPath(), file.GetContent(), 0644)
|
||||
if err != nil {
|
||||
log.Error(err.Error())
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &portal.FileCpResponse{State: portal.State_UNKNOWN}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user