Automatically delete empty recordings

This commit is contained in:
0xboobface 2019-06-01 16:35:57 +02:00
parent 501f685626
commit c0167155f3
1 changed files with 11 additions and 14 deletions

View File

@ -117,8 +117,7 @@ public class NextGenLocalRecorder implements Recorder {
Model model = recording.getModel();
tryRestartRecording(model);
} else {
// TODO is this ok?
setRecordingStatus(recording, State.FAILED);
if(recording.getStatus() != State.DELETED) {
recordingsLock.lock();
try {
recordingManager.delete(recording);
@ -128,6 +127,8 @@ public class NextGenLocalRecorder implements Recorder {
recordingsLock.unlock();
}
}
setRecordingStatus(recording, State.FAILED);
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
@ -255,12 +256,8 @@ public class NextGenLocalRecorder implements Recorder {
private boolean deleteIfTooShort(Recording rec) throws IOException, ParseException, PlaylistException {
Duration minimumLengthInSeconds = Duration.ofSeconds(Config.getInstance().getSettings().minimumLengthInSeconds);
if (minimumLengthInSeconds.getSeconds() <= 0) {
return false;
}
Duration recordingLength = rec.getLength();
if (recordingLength.compareTo(minimumLengthInSeconds) < 0) {
if (recordingLength.compareTo(minimumLengthInSeconds) < 0 || recordingLength.isZero()) {
recordingManager.delete(rec);
return true;
}