forked from j62/ctbrec
1
0
Fork 0

Fix bug in precondition check, which caused recordings to get restarted

The bug occured when model groups were used in combination with
priorities.
This commit is contained in:
0xb00bface 2021-06-04 15:47:21 +02:00
parent 0b25c68bdb
commit 12899cac4c
2 changed files with 11 additions and 3 deletions

View File

@ -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
========================

View File

@ -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<Model> 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()))