fix(avatar): gracefully degrade when avatar directory is not writable

AppAvatar::init() create_dir_all failure now logs a warning instead of
failing fatally. This fixes the email worker crash — it runs AppService
but has no PVC mount, so /data/avatars is not accessible. Other services
(app) have the PVC mounted and are unaffected.
This commit is contained in:
ZhenYi 2026-05-12 18:05:55 +08:00
parent cac342bdc5
commit d19a3ca557

View File

@ -17,7 +17,9 @@ impl AppAvatar {
pub async fn init(cfg: &AppConfig) -> anyhow::Result<Self> {
let path = cfg.avatar_path()?;
if std::fs::read_dir(&path).is_err() {
std::fs::create_dir_all(&path)?;
if let Err(e) = std::fs::create_dir_all(&path) {
tracing::warn!(path = %path, error = %e, "Avatar directory not available, avatars disabled");
}
}
let basic_path = PathBuf::from(path);
Ok(Self { basic_path })