Fix bug in precondition check ensureNoOtherFromModelGroupIsRecording

The check used model objects from the model group, which might have been old serialized objects with an outdated state.
The model from the model group is now updated with the current state from the recorder before performing the check.
This commit is contained in:
0xb00bface 2022-11-11 17:29:17 +01:00
parent 2cc55508b7
commit 5b62b2dba8
1 changed files with 4 additions and 3 deletions

View File

@ -24,8 +24,8 @@ public class RecordingPreconditions {
private static final Logger LOG = LoggerFactory.getLogger(RecordingPreconditions.class);
private Config config;
private NextGenLocalRecorder recorder;
private final Config config;
private final NextGenLocalRecorder recorder;
private long lastPreconditionMessage = 0;
@ -94,6 +94,7 @@ public class RecordingPreconditions {
long now = System.currentTimeMillis();
if ((now - lastPreconditionMessage) > TimeUnit.MINUTES.toMillis(1)) {
LOG.info("The number of downloads is maxed out");
lastPreconditionMessage = now;
}
// check, if we can stop a recording for a model with lower priority
Optional<Recording> lowerPrioRecordingProcess = recordingProcessWithLowerPrio(model.getPriority());
@ -194,7 +195,7 @@ public class RecordingPreconditions {
}
private Optional<Model> getModelForUrl(String modelUrl) {
return config.getSettings().models.stream()
return recorder.getModels().stream()
.filter(m -> Objects.equals(m.getUrl(), modelUrl))
.findFirst();
}