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

@ -398,6 +398,14 @@ allow_profile_lookup_federation_requests = true
# Disabled by default.
#media_compat_file_link = false
# Prunes missing media from the database as part of the media startup checks. This means if you
# delete files from the media directory the corresponding entries will be removed from the
# database. This is disabled by default because if the media directory is accidentally moved or
# inaccessible the metadata entries in the database will be lost with sadness.
#
# Disabled by default.
#prune_missing_media = false
# Checks consistency of the media directory at startup:
# 1. When `media_compat_file_link` is enbled, this check will upgrade media when switching back
# and forth between Conduit and Conduwuit. Both options must be enabled to handle this.

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..."