From 77fa7eba404697436407d366c47851eef4d3a12a Mon Sep 17 00:00:00 2001 From: 0xboobface <0xboobface@gmail.com> Date: Sun, 21 Apr 2019 16:11:03 +0200 Subject: [PATCH] Don't start recordings, if the recorder has been shut down --- .../main/java/ctbrec/recorder/LocalRecorder.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/common/src/main/java/ctbrec/recorder/LocalRecorder.java b/common/src/main/java/ctbrec/recorder/LocalRecorder.java index 72b7d67c..f4ecccf0 100644 --- a/common/src/main/java/ctbrec/recorder/LocalRecorder.java +++ b/common/src/main/java/ctbrec/recorder/LocalRecorder.java @@ -159,6 +159,11 @@ public class LocalRecorder implements Recorder { } private void startRecordingProcess(Model model) throws IOException { + if(!recording) { + // recorder is not in recording mode + return; + } + if(model.isSuspended()) { LOG.info("Recording for model {} is suspended.", model); return; @@ -214,12 +219,15 @@ public class LocalRecorder implements Recorder { } private void stopRecordingProcess(Model model) { + LOG.debug("Stopping recording for {}", model); Download download = recordingProcesses.get(model); recordingProcesses.remove(model); fireRecordingStateChanged(download.getTarget(), STOPPED, model, download.getStartTime()); Runnable stopAndThePostProcess = () -> { + LOG.debug("Stopping download for {}", model); download.stop(); + LOG.debug("Running post-processing for {}", model); createPostProcessor(download).run(); }; ppThreadPool.submit(stopAndThePostProcess); @@ -284,6 +292,11 @@ public class LocalRecorder implements Recorder { LOG.debug("Stopping all recording processes"); stopRecordingProcesses(); ppThreadPool.shutdown(); + try { + ppThreadPool.awaitTermination(5, TimeUnit.MINUTES); + } catch (InterruptedException e) { + LOG.error("Couldn't wait for post-processing to finish. Some recordings might be broken!"); + } client.shutdown(); }