refactor(runner): apply execution policy wrapping before command execution in OriginExecutionService

This commit is contained in:
2026-03-15 22:41:19 +08:00
parent a9993299a5
commit d55b849747

View File

@@ -2,8 +2,13 @@ package work.slhaf.partner.core.action.runner.execution;
import work.slhaf.partner.core.action.entity.MetaAction;
import work.slhaf.partner.core.action.runner.RunnerClient;
import work.slhaf.partner.core.action.runner.policy.ExecutionPolicyRegistry;
import work.slhaf.partner.core.action.runner.policy.WrappedLaunchSpec;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class OriginExecutionService {
@@ -17,7 +22,11 @@ public class OriginExecutionService {
RunnerClient.RunnerResponse response = new RunnerClient.RunnerResponse();
File file = new File(metaAction.getLocation());
String[] commands = commandExecutionService.buildCommands(metaAction.getLauncher(), metaAction.getParams(), file.getAbsolutePath());
CommandExecutionService.Result execResult = commandExecutionService.exec(commands);
WrappedLaunchSpec wrapped = ExecutionPolicyRegistry.INSTANCE.prepare(Arrays.stream(commands).toList());
List<String> wrappedCommands = new ArrayList<>();
wrappedCommands.add(wrapped.getCommand());
wrappedCommands.addAll(wrapped.getArgs());
CommandExecutionService.Result execResult = commandExecutionService.exec(wrappedCommands);
response.setOk(execResult.isOk());
response.setData(execResult.getTotal());
return response;