Skip to content

Commit

Permalink
fix: avoid external state modification for non-local runs
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-s committed Dec 6, 2024
1 parent 98c993f commit ffd5faa
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
import it.smartcommunitylabdhub.commons.models.relationships.RelationshipDetail;
import it.smartcommunitylabdhub.commons.models.run.Run;
import it.smartcommunitylabdhub.commons.models.run.RunBaseSpec;
import it.smartcommunitylabdhub.commons.models.run.RunBaseStatus;
import it.smartcommunitylabdhub.commons.models.specs.Spec;
import it.smartcommunitylabdhub.commons.models.task.Task;
import it.smartcommunitylabdhub.commons.services.LogService;
import it.smartcommunitylabdhub.commons.services.RelationshipsAwareEntityService;
import it.smartcommunitylabdhub.commons.services.SpecRegistry;
import it.smartcommunitylabdhub.commons.utils.KeyUtils;
import it.smartcommunitylabdhub.commons.utils.MapUtils;
import it.smartcommunitylabdhub.core.components.infrastructure.specs.SpecValidator;
import it.smartcommunitylabdhub.core.models.builders.run.RunEntityBuilder;
import it.smartcommunitylabdhub.core.models.entities.AbstractEntity_;
Expand Down Expand Up @@ -310,6 +312,14 @@ public Run updateRun(@NotNull String id, @NotNull Run dto)
dto.setSpec(current.getSpec());
}

//state is modifiable *only* for local runs
RunSpecAccessor specAccessor = RunSpecAccessor.with(current.getSpec());
if (!specAccessor.isLocalExecution()) {
//keep base status from current
RunBaseStatus bs = RunBaseStatus.with(current.getSpec());
dto.setStatus(MapUtils.mergeMultipleMaps(dto.getStatus(), bs.toMap()));
}

//TODO: implement logic to update status only in some states

//update, run is modifiable
Expand Down

0 comments on commit ffd5faa

Please sign in to comment.