Improve logging/exception messages in RecordingPreconditions

This commit is contained in:
0xb00bface 2022-08-07 18:31:52 +02:00
parent 2afd0820e5
commit 4e5287c177
1 changed files with 20 additions and 14 deletions

View File

@ -1,5 +1,12 @@
package ctbrec.recorder; 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.io.IOException;
import java.security.InvalidKeyException; import java.security.InvalidKeyException;
@ -11,14 +18,7 @@ import java.util.Optional;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.slf4j.Logger; import static ctbrec.recorder.NextGenLocalRecorder.IGNORE_CACHE;
import org.slf4j.LoggerFactory;
import ctbrec.Config;
import ctbrec.Model;
import ctbrec.ModelGroup;
import ctbrec.Recording;
import ctbrec.recorder.download.Download;
public class RecordingPreconditions { public class RecordingPreconditions {
@ -168,8 +168,14 @@ public class RecordingPreconditions {
return; return;
} else { } else {
Optional<Model> otherModel = getModelForUrl(modelUrl); Optional<Model> otherModel = getModelForUrl(modelUrl);
if (otherModel.isPresent() && (otherModelIsRecorded(otherModel.get()) || otherModelCanBeRecorded(otherModel.get()))) { if (otherModel.isPresent()) {
if (otherModelIsRecorded(otherModel.get())) {
throw new PreconditionNotMetException(otherModel.get() + " from the same group is already recorded"); 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);
} }
} }
} }