forked from j62/ctbrec
1
0
Fork 0

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,16 +117,17 @@ public class NextGenLocalRecorder implements Recorder {
Model model = recording.getModel();
tryRestartRecording(model);
} else {
// TODO is this ok?
setRecordingStatus(recording, State.FAILED);
recordingsLock.lock();
try {
recordingManager.delete(recording);
} catch (IOException e) {
LOG.error("Couldn't delete recording {}", recording, e);
} finally {
recordingsLock.unlock();
if(recording.getStatus() != State.DELETED) {
recordingsLock.lock();
try {
recordingManager.delete(recording);
} catch (IOException e) {
LOG.error("Couldn't delete recording {}", recording, e);
} finally {
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;
}