Fix switching between "record later" and "recording"
Starting the recording coming from "record later" did not work in every case (client/server, standalone, start, start paused, record until)
This commit is contained in:
parent
d663ca1160
commit
6e5d706f65
|
@ -69,6 +69,9 @@ public class StartRecordingAction extends AbstractModelAction {
|
|||
}
|
||||
}
|
||||
|
||||
if (showRecordUntilDialog) {
|
||||
model.setSuspended(false);
|
||||
}
|
||||
new StartRecordingTask(recorder).executeSync(model)
|
||||
.whenComplete((mdl, ex) -> result.add(new Result(mdl, ex)));
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ public abstract class AbstractModelTask {
|
|||
|
||||
public CompletableFuture<Model> executeSync(Model model) {
|
||||
try {
|
||||
org.slf4j.LoggerFactory.getLogger(getClass()).debug("Executing concrete task for {} - suspended:{}", model, model.isSuspended());
|
||||
concreteTask.accept(model);
|
||||
return CompletableFuture.completedFuture(model);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -265,8 +265,8 @@ public class NextGenLocalRecorder implements Recorder {
|
|||
|
||||
@Override
|
||||
public void addModel(Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
|
||||
Optional<Model> existing = findModel(model);
|
||||
if (!existing.isPresent()) {
|
||||
Optional<Model> result = findModel(model);
|
||||
if (!result.isPresent()) {
|
||||
LOG.info("Model {} added", model);
|
||||
recorderLock.lock();
|
||||
try {
|
||||
|
@ -280,9 +280,21 @@ public class NextGenLocalRecorder implements Recorder {
|
|||
recorderLock.unlock();
|
||||
}
|
||||
startRecordingProcess(model);
|
||||
} else {
|
||||
Model existing = result.get();
|
||||
copyModelProperties(model, existing);
|
||||
startRecordingProcess(existing);
|
||||
}
|
||||
}
|
||||
|
||||
private void copyModelProperties(Model src, Model existing) {
|
||||
existing.setSuspended(src.isSuspended());
|
||||
existing.setMarkedForLaterRecording(src.isMarkedForLaterRecording());
|
||||
existing.setPriority(src.getPriority());
|
||||
existing.setRecordUntil(src.getRecordUntil());
|
||||
existing.setRecordUntilSubsequentAction(src.getRecordUntilSubsequentAction());
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> startRecordingProcess(Model model) {
|
||||
return CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
|
|
|
@ -98,6 +98,10 @@ public class RemoteRecorder implements Recorder {
|
|||
|
||||
@Override
|
||||
public void addModel(Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
|
||||
LOG.trace("Model marked: {}", model.isMarkedForLaterRecording());
|
||||
LOG.trace("Model paused: {}", model.isSuspended());
|
||||
LOG.trace("Model until: {}", model.getRecordUntil().equals(Instant.ofEpochMilli(Model.RECORD_INDEFINITELY)) ? "no limit" : model.getRecordUntil());
|
||||
LOG.trace("Model after: {}", model.getRecordUntilSubsequentAction());
|
||||
sendRequest("start", model);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,10 @@ public class RecorderServlet extends AbstractCtbrecServlet {
|
|||
switch (request.action) {
|
||||
case "start":
|
||||
LOG.debug("Starting recording for model {} - {}", request.model.getName(), request.model.getUrl());
|
||||
LOG.trace("Model marked: {}", request.model.isMarkedForLaterRecording());
|
||||
LOG.trace("Model paused: {}", request.model.isSuspended());
|
||||
LOG.trace("Model until: {}", request.model.getRecordUntil().equals(Instant.ofEpochMilli(Model.RECORD_INDEFINITELY)) ? "no limit" : request.model.getRecordUntil());
|
||||
LOG.trace("Model after: {}", request.model.getRecordUntilSubsequentAction());
|
||||
recorder.addModel(request.model);
|
||||
String response = "{\"status\": \"success\", \"msg\": \"Recording started\"}";
|
||||
responseWriter.write(response);
|
||||
|
|
Loading…
Reference in New Issue