From d19a3ca55709bbc7798f0f2180290a5f43ece6b8 Mon Sep 17 00:00:00 2001 From: ZhenYi <434836402@qq.com> Date: Tue, 12 May 2026 18:05:55 +0800 Subject: [PATCH] fix(avatar): gracefully degrade when avatar directory is not writable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- libs/avatar/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/avatar/lib.rs b/libs/avatar/lib.rs index f1aa0cd..f7a9ba5 100644 --- a/libs/avatar/lib.rs +++ b/libs/avatar/lib.rs @@ -17,7 +17,9 @@ impl AppAvatar { pub async fn init(cfg: &AppConfig) -> anyhow::Result { 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 })