diff --git a/common/src/main/java/ctbrec/recorder/RecordingPreconditions.java b/common/src/main/java/ctbrec/recorder/RecordingPreconditions.java index 8f50e22f..6bb431cb 100644 --- a/common/src/main/java/ctbrec/recorder/RecordingPreconditions.java +++ b/common/src/main/java/ctbrec/recorder/RecordingPreconditions.java @@ -1,5 +1,12 @@ package ctbrec.recorder; -import static ctbrec.recorder.NextGenLocalRecorder.*; + +import ctbrec.Config; +import ctbrec.Model; +import ctbrec.ModelGroup; +import ctbrec.Recording; +import ctbrec.recorder.download.Download; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.security.InvalidKeyException; @@ -11,14 +18,7 @@ import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import ctbrec.Config; -import ctbrec.Model; -import ctbrec.ModelGroup; -import ctbrec.Recording; -import ctbrec.recorder.download.Download; +import static ctbrec.recorder.NextGenLocalRecorder.IGNORE_CACHE; public class RecordingPreconditions { @@ -59,7 +59,7 @@ public class RecordingPreconditions { LocalTime now = LocalTime.now(); if (start.isBefore(end) && now.isAfter(start) && now.isBefore(end)) { throw new PreconditionNotMetException("Current time is in recording timeout " + start + " - " + end); - } else if(start.isAfter(end) && !(now.isAfter(end) && now.isBefore(start))) { // NOSONAR + } else if (start.isAfter(end) && !(now.isAfter(end) && now.isBefore(start))) { // NOSONAR throw new PreconditionNotMetException("Current time is in recording timeout " + start + " - " + end); } } @@ -168,8 +168,14 @@ public class RecordingPreconditions { return; } else { Optional otherModel = getModelForUrl(modelUrl); - if (otherModel.isPresent() && (otherModelIsRecorded(otherModel.get()) || otherModelCanBeRecorded(otherModel.get()))) { - throw new PreconditionNotMetException(otherModel.get() + " from the same group is already recorded"); + if (otherModel.isPresent()) { + if (otherModelIsRecorded(otherModel.get())) { + throw new PreconditionNotMetException(otherModel.get() + " from the same group is already recorded"); + } else if (otherModelCanBeRecorded(otherModel.get())) { + throw new PreconditionNotMetException(otherModel.get() + " from the same group can be recorded"); + } + } else { + LOG.warn("Couldn't check if model from same group has higer prio for {}", modelUrl); } } } @@ -182,8 +188,8 @@ public class RecordingPreconditions { private void stopModelsWithLowerPrio(ModelGroup modelGroup) throws InvalidKeyException, NoSuchAlgorithmException, IOException { recorder.getCurrentlyRecording().stream() - .filter(m -> modelGroup.getModelUrls().contains(m.getUrl())) - .forEach(recorder::stopRecordingProcess); + .filter(m -> modelGroup.getModelUrls().contains(m.getUrl())) + .forEach(recorder::stopRecordingProcess); }