add config option for pruning missing media

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-08-27 01:46:09 +00:00
parent 9654dd9218
commit 73af171830
3 changed files with 12 additions and 1 deletions

View file

@ -293,6 +293,8 @@ pub struct Config {
pub media_startup_check: bool,
#[serde(default)]
pub media_compat_file_link: bool,
#[serde(default)]
pub prune_missing_media: bool,
#[serde(default = "Vec::new")]
pub prevent_media_downloads_from: Vec<OwnedServerName>,
@ -742,6 +744,7 @@ impl fmt::Display for Config {
line("RocksDB Statistics level", &self.rocksdb_stats_level.to_string());
line("Media integrity checks on startup", &self.media_startup_check.to_string());
line("Media compatibility filesystem links", &self.media_compat_file_link.to_string());
line("Prune missing media from database", &self.prune_missing_media.to_string());
line("Prevent Media Downloads From", {
let mut lst = vec![];
for domain in &self.prevent_media_downloads_from {

View file

@ -833,7 +833,7 @@ async fn handle_media_check(
.map_or(false, |md| md.is_symlink())
};
if !old_exists && !new_exists {
if config.prune_missing_media && !old_exists && !new_exists {
error!(
media_id = ?encode_key(key), ?new_path, ?old_path,
"Media is missing at all paths. Removing from database..."