forked from j62/ctbrec
1
0
Fork 0

Don't start recordings, if the recorder has been shut down

This commit is contained in:
0xboobface 2019-04-21 16:11:03 +02:00
parent ee3ae3ef43
commit 77fa7eba40
1 changed files with 13 additions and 0 deletions

View File

@ -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();
}