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