| 1390 | } |
| 1391 | |
| 1392 | func (ws *WshServer) SetVarCommand(ctx context.Context, data wshrpc.CommandVarData) error { |
| 1393 | _, fileData, err := filestore.WFS.ReadFile(ctx, data.ZoneId, data.FileName) |
| 1394 | if err == fs.ErrNotExist { |
| 1395 | fileData = []byte{} |
| 1396 | err = filestore.WFS.MakeFile(ctx, data.ZoneId, data.FileName, nil, wshrpc.FileOpts{}) |
| 1397 | if err != nil { |
| 1398 | return fmt.Errorf("error creating blockfile: %w", err) |
| 1399 | } |
| 1400 | } else if err != nil { |
| 1401 | return fmt.Errorf("error reading blockfile: %w", err) |
| 1402 | } |
| 1403 | envMap := envutil.EnvToMap(string(fileData)) |
| 1404 | if data.Remove { |
| 1405 | delete(envMap, data.Key) |
| 1406 | } else { |
| 1407 | envMap[data.Key] = data.Val |
| 1408 | } |
| 1409 | envStr := envutil.MapToEnv(envMap) |
| 1410 | return filestore.WFS.WriteFile(ctx, data.ZoneId, data.FileName, []byte(envStr)) |
| 1411 | } |
| 1412 | |
| 1413 | func (ws *WshServer) PathCommand(ctx context.Context, data wshrpc.PathCommandData) (string, error) { |
| 1414 | pathType := data.PathType |