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