From b9e6d67d15bbcc2ffada13f26f2c35e897cea6a5 Mon Sep 17 00:00:00 2001 From: asonix Date: Sat, 22 Jul 2023 18:37:25 -0500 Subject: [PATCH] Add retention configuration This doesn't do anything yet, but is part of the Media Proxy and Variant Cleanup tickets --- defaults.toml | 6 +++ src/config/commandline.rs | 45 ++++++++++++++++ src/config/defaults.rs | 18 +++++++ src/config/file.rs | 11 +++- src/config/primitives.rs | 110 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 189 insertions(+), 1 deletion(-) diff --git a/defaults.toml b/defaults.toml index 9a0be3c..6ac6616 100644 --- a/defaults.toml +++ b/defaults.toml @@ -19,6 +19,8 @@ buffer_capacity = 102400 service_name = "pict-rs" targets = "info" +[metrics] + [old_db] path = "/mnt" @@ -32,6 +34,10 @@ filters = [ "thumbnail", ] +[media.retention] +variants = "7d" +proxy = "7d" + [media.image] max_width = 10000 max_height = 10000 diff --git a/src/config/commandline.rs b/src/config/commandline.rs index fc5421c..282be5b 100644 --- a/src/config/commandline.rs +++ b/src/config/commandline.rs @@ -7,6 +7,8 @@ use clap::{Parser, Subcommand}; use std::{net::SocketAddr, path::PathBuf}; use url::Url; +use super::primitives::RetentionValue; + impl Args { pub(super) fn into_output(self) -> Output { let Args { @@ -51,6 +53,8 @@ impl Args { metrics_prometheus_address, media_preprocess_steps, media_max_file_size, + media_retention_variants, + media_retention_proxy, media_image_max_width, media_image_max_height, media_image_max_area, @@ -109,6 +113,11 @@ impl Args { prometheus_address: metrics_prometheus_address, }; + let retention = Retention { + variants: media_retention_variants, + proxy: media_retention_proxy, + }; + let image_quality = ImageQuality { avif: media_image_quality_avif, jpeg: media_image_quality_jpeg, @@ -170,6 +179,7 @@ impl Args { max_file_size: media_max_file_size, preprocess_steps: media_preprocess_steps, filters: media_filters, + retention: retention.set(), image: image.set(), animation: animation.set(), video: video.set(), @@ -453,6 +463,8 @@ struct Media { #[serde(skip_serializing_if = "Option::is_none")] filters: Option>, #[serde(skip_serializing_if = "Option::is_none")] + retention: Option, + #[serde(skip_serializing_if = "Option::is_none")] image: Option, #[serde(skip_serializing_if = "Option::is_none")] animation: Option, @@ -460,6 +472,27 @@ struct Media { video: Option