forked from j62/ctbrec
1
0
Fork 0

Added setting to delete orphaned recording metadata (switched off by default)

This commit is contained in:
0xb00bface 2023-12-30 13:23:36 +01:00
parent 3caefd6bb4
commit 932974137c
3 changed files with 18 additions and 8 deletions

View File

@ -131,6 +131,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
private PostProcessingStepPanel postProcessingStepPanel; private PostProcessingStepPanel postProcessingStepPanel;
private SimpleStringProperty filterBlacklist; private SimpleStringProperty filterBlacklist;
private SimpleStringProperty filterWhitelist; private SimpleStringProperty filterWhitelist;
private SimpleBooleanProperty deleteOrphanedRecordingMetadata;
public SettingsTab(List<Site> sites, Recorder recorder) { public SettingsTab(List<Site> sites, Recorder recorder) {
this.sites = sites; this.sites = sites;
@ -211,6 +212,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
checkForUpdates = new SimpleBooleanProperty(null, "checkForUpdates", settings.checkForUpdates); checkForUpdates = new SimpleBooleanProperty(null, "checkForUpdates", settings.checkForUpdates);
filterBlacklist = new SimpleStringProperty(null, "filterBlacklist", settings.filterBlacklist); filterBlacklist = new SimpleStringProperty(null, "filterBlacklist", settings.filterBlacklist);
filterWhitelist = new SimpleStringProperty(null, "filterWhitelist", settings.filterWhitelist); filterWhitelist = new SimpleStringProperty(null, "filterWhitelist", settings.filterWhitelist);
deleteOrphanedRecordingMetadata = new SimpleBooleanProperty(null, "deleteOrphanedRecordingMetadata", settings.deleteOrphanedRecordingMetadata);
} }
private void createGui() { private void createGui() {
@ -281,7 +283,8 @@ public class SettingsTab extends Tab implements TabSelectionListener {
Setting.of("FFmpeg parameters", ffmpegParameters, "FFmpeg parameters to use when merging stream segments"), Setting.of("FFmpeg parameters", ffmpegParameters, "FFmpeg parameters to use when merging stream segments"),
Setting.of("File Extension", fileExtension, "File extension to use for recordings"), Setting.of("File Extension", fileExtension, "File extension to use for recordings"),
Setting.of("Check online state every (seconds)", onlineCheckIntervalInSecs, "Check every x seconds, if a model came online"), Setting.of("Check online state every (seconds)", onlineCheckIntervalInSecs, "Check every x seconds, if a model came online"),
Setting.of("Skip online check for paused models", onlineCheckSkipsPausedModels, "Skip online check for paused models")), Setting.of("Skip online check for paused models", onlineCheckSkipsPausedModels, "Skip online check for paused models"),
Setting.of("Delete orphaned recording metadata", deleteOrphanedRecordingMetadata, "Delete recordings for which the video files are missing on start")),
Group.of("Timeout", Group.of("Timeout",
Setting.of("Don't record from", timeoutRecordingStartingAt), Setting.of("Don't record from", timeoutRecordingStartingAt),
Setting.of("Until", timeoutRecordingEndingAt) Setting.of("Until", timeoutRecordingEndingAt)

View File

@ -66,6 +66,7 @@ public class Settings {
public String contactsheetTimestampLook = "font=sans-serif:fontcolor=white:fontsize=60:box=1:boxcolor=black@0.5:boxborderw=5"; public String contactsheetTimestampLook = "font=sans-serif:fontcolor=white:fontsize=60:box=1:boxcolor=black@0.5:boxborderw=5";
public String dateTimeFormat = ""; public String dateTimeFormat = "";
public int defaultPriority = 50; public int defaultPriority = 50;
public boolean deleteOrphanedRecordingMetadata = false;
public boolean determineResolution = false; public boolean determineResolution = false;
public List<String> disabledSites = new ArrayList<>(); public List<String> disabledSites = new ArrayList<>();
public String downloadFilename = "$sanitize(${modelName})_$format(${localDateTime})"; public String downloadFilename = "$sanitize(${modelName})_$format(${localDateTime})";

View File

@ -103,10 +103,16 @@ public class RecordingManager {
} }
if (recordingExists(recording)) { if (recordingExists(recording)) {
recordings.add(recording); recordings.add(recording);
} else {
if (config.getSettings().deleteOrphanedRecordingMetadata) {
log.info("Recording {} does not exist anymore -> deleting recording", recording);
boolean deleted = Files.deleteIfExists(new File(recording.getMetaDataFile()).toPath());
log.info("Recording {} has {}been deleted", recording, deleted ? "" : "not ");
} else { } else {
log.info("Recording {} does not exist anymore -> ignoring recording", recording); log.info("Recording {} does not exist anymore -> ignoring recording", recording);
} }
} }
}
private boolean recordingExists(Recording recording) { private boolean recordingExists(Recording recording) {
return recording.getAbsoluteFile().exists(); return recording.getAbsoluteFile().exists();