Only update recordings, if they might have been changed
This commit is contained in:
parent
b2e8be5a59
commit
e3dec420fd
|
@ -1,6 +1,11 @@
|
|||
package ctbrec;
|
||||
|
||||
import static ctbrec.Recording.State.*;
|
||||
import ctbrec.event.EventBusHolder;
|
||||
import ctbrec.event.RecordingStateChangedEvent;
|
||||
import ctbrec.io.IoUtils;
|
||||
import ctbrec.recorder.download.Download;
|
||||
import ctbrec.recorder.download.VideoLengthDetector;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -15,17 +20,10 @@ import java.util.Optional;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ctbrec.event.EventBusHolder;
|
||||
import ctbrec.event.RecordingStateChangedEvent;
|
||||
import ctbrec.io.IoUtils;
|
||||
import ctbrec.recorder.download.Download;
|
||||
import ctbrec.recorder.download.VideoLengthDetector;
|
||||
import static ctbrec.Recording.State.*;
|
||||
|
||||
@Slf4j
|
||||
public class Recording implements Serializable, Callable<Recording> {
|
||||
private static final transient Logger LOG = LoggerFactory.getLogger(Recording.class);
|
||||
|
||||
private String id;
|
||||
private Model model;
|
||||
|
@ -44,6 +42,11 @@ public class Recording implements Serializable, Callable<Recording> {
|
|||
private File postProcessedFile = null;
|
||||
private int selectedResolution = -1;
|
||||
|
||||
/**
|
||||
* Signals, if the recording has been changed and it has to be refreshed
|
||||
*/
|
||||
private boolean dirtyFlag = true;
|
||||
|
||||
public enum State {
|
||||
RECORDING("recording"),
|
||||
GENERATING_PLAYLIST("generating playlist"),
|
||||
|
@ -268,7 +271,7 @@ public class Recording implements Serializable, Callable<Recording> {
|
|||
}
|
||||
return sum;
|
||||
} catch (IOException e) {
|
||||
LOG.error("Couldn't determine recording size", e);
|
||||
log.error("Couldn't determine recording size", e);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -288,7 +291,10 @@ public class Recording implements Serializable, Callable<Recording> {
|
|||
}
|
||||
|
||||
public void refresh() {
|
||||
sizeInByte = getSize();
|
||||
if ((status != FINISHED && status != FAILED) || dirtyFlag) {
|
||||
sizeInByte = getSize();
|
||||
dirtyFlag = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canBePostProcessed() {
|
||||
|
@ -309,4 +315,8 @@ public class Recording implements Serializable, Callable<Recording> {
|
|||
.findFirst()
|
||||
.map(File::new);
|
||||
}
|
||||
|
||||
public void setDirtyFlag(boolean dirtyFlag) {
|
||||
this.dirtyFlag = dirtyFlag;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -182,6 +182,7 @@ public class NextGenLocalRecorder implements Recorder {
|
|||
private void submitPostProcessingJob(Recording recording) {
|
||||
ppPool.submit(() -> {
|
||||
try {
|
||||
recording.setDirtyFlag(true);
|
||||
setRecordingStatus(recording, State.POST_PROCESSING);
|
||||
recording.getDownload().finalizeDownload();
|
||||
recording.refresh();
|
||||
|
|
Loading…
Reference in New Issue