diff --git a/CHANGELOG.md b/CHANGELOG.md index 2725862f..0883d084 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ * Added XloveCam * Improved Chaturbate search * Fixed tipping function +* Fixed bug in recording precondition check, which caused recordings to get + restarted. The bug occured when model groups were used in combination with + priorities. 4.3.1 ======================== diff --git a/common/src/main/java/ctbrec/recorder/RecordingPreconditions.java b/common/src/main/java/ctbrec/recorder/RecordingPreconditions.java index 0fdee9fb..94755245 100644 --- a/common/src/main/java/ctbrec/recorder/RecordingPreconditions.java +++ b/common/src/main/java/ctbrec/recorder/RecordingPreconditions.java @@ -31,6 +31,7 @@ public class RecordingPreconditions { } void check(Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException { + LOG.debug("Checking preconditions for model {}", model); ensureRecorderIsActive(); ensureModelIsNotSuspended(model); ensureModelIsNotMarkedForLaterRecording(model); @@ -38,9 +39,9 @@ public class RecordingPreconditions { ensureNoRecordingRunningForModel(model); ensureModelShouldBeRecorded(model); ensureEnoughSpaceForRecording(); - ensureDownloadSlotAvailable(model); - ensureModelIsOnline(model); ensureNoOtherFromModelGroupIsRecording(model); + ensureModelIsOnline(model); + ensureDownloadSlotAvailable(model); } private void ensureModelIsOnline(Model model) { @@ -147,7 +148,7 @@ public class RecordingPreconditions { return; } else { Optional otherModel = getModelForUrl(modelUrl); - if (otherModel.isPresent() && otherModelCanBeRecorded(otherModel.get())) { + if (otherModel.isPresent() && (otherModelIsRecorded(otherModel.get()) || otherModelCanBeRecorded(otherModel.get()))) { throw new PreconditionNotMetException(otherModel.get() + " from the same group is already recorded"); } } @@ -155,6 +156,10 @@ public class RecordingPreconditions { } } + private boolean otherModelIsRecorded(Model model) throws InvalidKeyException, NoSuchAlgorithmException, IOException { + return recorder.getCurrentlyRecording().contains(model); + } + private void stopModelsWithLowerPrio(ModelGroup modelGroup) throws InvalidKeyException, NoSuchAlgorithmException, IOException { recorder.getCurrentlyRecording().stream() .filter(m -> modelGroup.getModelUrls().contains(m.getUrl()))