Compare commits

...

2 Commits

Author SHA1 Message Date
ZhenYi
e6ba5433e2 bucong 提交 2026-05-12 18:06:20 +08:00
ZhenYi
d19a3ca557 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.
2026-05-12 18:05:55 +08:00
4 changed files with 6 additions and 3 deletions

1
Cargo.lock generated
View File

@ -1149,6 +1149,7 @@ dependencies = [
"config",
"image",
"serde",
"tracing",
]
[[package]]

View File

@ -19,5 +19,6 @@ config = { workspace = true }
anyhow = { workspace = true }
image = { workspace = true }
serde = { workspace = true, features = ["derive"] }
tracing = { workspace = true }
[lints]
workspace = true

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 })

View File

@ -2,7 +2,6 @@ import path from "path"
import tailwindcss from "@tailwindcss/vite"
import react from "@vitejs/plugin-react"
import {defineConfig, type Plugin} from "vite"
import {analyzer} from 'vite-bundle-analyzer'
function tailwindEscapeFix(): Plugin {
return {
@ -17,7 +16,7 @@ function tailwindEscapeFix(): Plugin {
}
export default defineConfig({
plugins: [tailwindcss(), tailwindEscapeFix(), react(), analyzer()],
plugins: [tailwindcss(), tailwindEscapeFix(), react()],
optimizeDeps: {
entries: ["src/**/*.{ts,tsx}"],
},